In my Model, I'm trying to associate 2 different things with a Course, using hasMany. The idea is that there are 'Courseinstances', which are just sets of dates on which the Course runs, and 'Courseinstancesupcoming', which are future dates only. I came up with the following (in Course.php):
public $hasMany = array(
'Courseinstance' => array(
'className' => 'Courseinstance',
'foreignKey' => 'course_id',
'order' => 'datestart ASC'
),
'Courseinstanceupcoming' => array(
'className' => 'Courseinstance',
'foreignKey' => 'course_id',
'order' => 'datestart ASC',
'conditions' => array(
'datestart > ' => date('Y-m-d H:i:s')
)
)
);
Now, I'm not sure if this is a good thing to be even trying to do, but when I run it, I get the following error:
Error: syntax error, unexpected '(', expecting ',' or ';'
File: C:\wamp\www\RNNI\site\app\Model\Course.php
I tried various things, but got the same error. Then I tried adding the following line:
var $date = date('Y-m-d H:i:s');
and this is now throwing an error instead (same error, but now on this line instead of the hasMany line).
If I do
var $date = 'testing';
instead, it copes fine. Is there something which prevents me from using the PHP date() function in a model in this way?
And if anyone can suggest a solution to the initial problem of having 2 types of objects in the hasMany, that'd also be good, but it's not so urgent, as I can work around that one.
Thanks in advance for any help!
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment