日期beetween和查询给出错误

时间:2016-07-19 11:27:28

标签: cakephp

$attData= $attendeesTable->find()->where( [
    'meeting_id =' => $meeting_id,
    'email =' => $data['email'],
    'created_at BETWEEN ? AND ?'=> array(
        $finaldate,
        $enddate
    )
])
->count();

错误:在非对象上调用成员函数format() 档案/var/www/webinar.mj/vendor/cakephp/cakephp/src/Database/Type/DateTimeType.php 行:104

1 个答案:

答案 0 :(得分:0)

正确的方法是

$attData= $attendeesTable->find()->where( [
    'meeting_id =' => $meeting_id,
    'email =' => $data['email'],
    'created_at BETWEEN :foo AND :bar'
])
->bind(':foo', $finaldate, 'date') 
->bind(':bar', $enddate, 'date') ;
->count();

你也可以

$stateProvider
  .state('state',{
    url: '',
    views: {
      'header': {
        templateUrl: 'views/header.html',
        controller: 'headerCtrl'
      },
      'content': {
        template: '<div ui-view=" "></div>',  //<-- child templates loaded to here
      },
      'footer': {
        templateUrl: 'views/footer.html',
        controller: 'footerCtrl'
      }
    }
  })
  .state('state.post', {
    url: 'news/:id/:KeyWords'
    templateUrl: 'views/post.html'   //<-- This goes into content's ui-view
  });