2012-02-09 2 views
0

Вы видите здесь синтаксические ошибки?ошибка cakephp: неожиданный '(', expecting ')', является ли мой синтаксис неправильным?

'Coupon'=>array(
      'fields'=>array(
       'promo_code','desc' 
      ), 
      'conditions'=>array(
         'OR'=>array(
          'expires' =>0, 
          'Coupon.end_date >'=>date('Y-m-d') 
         ) 
      ) 
     ), 

Это часть моего массива «содержать» в моем коде контроллера. Когда я удаляю этот фрагмент из своего кода, торт отлично работает (мне нужна эта часть!). Опубликуйте весь отчет ниже. Помогите?

public $paginate = array(
    'Location'=>array(
     'joins' => array(
      array( 
       'table' => 'locations_tags', 
       'alias' => 'LocationsTag', 
       'type' => 'inner', 
       'conditions'=> array( 
       'LocationsTag.location_id = Location.id' 
       ) 
      ) 
     ), 
     'limit'=>9, 
     'contain'=>array(
     'Course'=>array(
      'fields'=>array(
       'specials', 'contact','desc' 
       ), 
      'conditions'=>array('Course.active'=>1) 
      ), 
     'Charter'=>array(
      'fields'=>array(
       'book','specials', 'contact','desc' 
       ), 
      'conditions'=>array('Charter.active'=>1) 
      ), 
     'Restaurant'=>array(
      'fields'=>array(
       'menu','wine_list','specials', 'contact','desc' 
       ), 
      'conditions'=>array('Restaurant.active'=>1) 
      ), 
     'Nightclub'=>array(
      'fields'=>array(
       'menu','schedule','specials', 'contact','desc' 
       ), 
      'conditions'=>array('Nightclub.active'=>1) 
      ), 
     'Store'=>array(
      'fields'=>array(
       'catalog','specials', 'contact','desc' 
       ), 
      'conditions'=>array('Store.active'=>1) 
      ), 
     'Coupon'=>array(
      'fields'=>array(
       'promo_code','desc' 
      ), 
      'conditions'=>array(
         'OR'=>array(
          'expires' =>0, 
          'Coupon.end_date >'=>date('Y-m-d') 
         ) 
      ) 
     ), 
     'Image', 
     'Tag'=>array(
      'fields'=>array(
       'seo_tag' 
      ) 
      ) 
     ) 
    ) 
); 
+0

Какая линия бросает ошибку? – Blender

ответ

2
 'Coupon.end_date >'=>date('Y-m-d') 

Вы не можете назначить вычисленные значения (например, при вызове функций) в объявлениях класса собственности. Они должны быть постоянными значениями.

Для вычисленного значения вам необходимо назначить это в конструкторе или что-то в этом роде.

От the docs:

This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated.

+0

Спасибо. oohhhhhhhkay, теперь, чтобы понять, что часть ..... – huzzah

Смежные вопросы