Database design . Beginner having trouble.
I have two database tables. Tenants and expenses. Tenant has many expenses. Expense belongs to tenant. When ever a new expense is created a tenant who has paid for the expense is associated with it. Now i want another relationship which is "affects". Each expense may not affect all tenants. So while creating an expense i need to mention using multiple select all tenants who are affected by the expense. How and what should i design the database tables. ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
How and where to insert a tracking script. ?
I want to insert a small counter and a login code so that they are run on all cake pages. I am using default theme and css. Tell me the default template file so that i can insert these codes. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: $this->find not interpreting "LIKE"
thanks, i will try it On Dec 10, 12:58 pm, AD7six <[EMAIL PROTECTED]> wrote: > On Dec 10, 4:13 am, Tanay <[EMAIL PROTECTED]> wrote: > > > > > $expenses=$this->Expense->find('all',array( > > 'conditions'=> array( > > 'Expense.Name'=>'LIKE S%' ))); > > > the query generated from sql dump: > > > SELECT `Expense`.`id`, `Expense`.`name`, `Expense`.`description`, > > `Expense`.`amount`, `Expense`.`date`, `Expense`.`tenant_id`, > > `Tenant`.`id`, `Tenant`.`name` FROM `expenses` AS `Expense` LEFT JOIN > > `tenants` AS `Tenant` ON (`Expense`.`tenant_id` = `Tenant`.`id`) WHERE > > `Expense`.`Name` = 'LIKE S%' > > > > > at the end i want 'Expense'.'name' LIKE 'S%' > > but its giving `Expense`.`Name` = 'LIKE S%' > > > whats wrong with my cakephp syntax? > > 'Expense.Name LIKE'=>' S%' > or > 'Expense.Name LIKE ?%'=>' S' > > https://trac.cakephp.org/changeset/7075- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
$this->find not interpreting "LIKE"
$expenses=$this->Expense->find('all',array( 'conditions'=> array( 'Expense.Name'=>'LIKE S%' ))); the query generated from sql dump: SELECT `Expense`.`id`, `Expense`.`name`, `Expense`.`description`, `Expense`.`amount`, `Expense`.`date`, `Expense`.`tenant_id`, `Tenant`.`id`, `Tenant`.`name` FROM `expenses` AS `Expense` LEFT JOIN `tenants` AS `Tenant` ON (`Expense`.`tenant_id` = `Tenant`.`id`) WHERE `Expense`.`Name` = 'LIKE S%' at the end i want 'Expense'.'name' LIKE 'S%' but its giving `Expense`.`Name` = 'LIKE S%' whats wrong with my cakephp syntax? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
sending parameters to a controller function
i have a class type "expenses" the index() function of controller lists all expenses' then i have a function show(month,year) which lists all expenses of that particular month,year in expenses home page i want to have a form with two select buttons such that i select month and year with values, so i inserted html for select button now on clicking submit button, i want the control to be taken to showmonth/month/year how can i do this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: ORM, fetching related rows of corresponding model: undefined index..
thanks a lot, my dumb mistake.. On Dec 8, 4:51 pm, grigri <[EMAIL PROTECTED]> wrote: > Your model files are incorrectly named. > > Model files should be named as singular, lowercase, underscored - > yours are plural. > > Rename 'models/questions.php' to 'models/question.php' and 'models/ > answers.php' to 'models/answer.php'. Everthing else looks ok. > > hth > grigri > > On Dec 8, 11:11 am, Tanay <[EMAIL PROTECTED]> wrote: > > > no sight of 'answers' still > > > On Dec 8, 4:10 pm, Tanay <[EMAIL PROTECTED]> wrote: > > > > i changed the value to 2, > > > still the var_ dump is like this: > > > > array(2) { [0]=> array(1) { ["Question"]=> array(5) { ["id"]=> string > > > (1) "1" ["question"]=> string(22) "Why do you use > > > CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) > > > "2008-02-11 22:19:04" ["modified"]=> string(19) "2008-02-11 > > > 22:19:04" } } [1]=> array(1) { ["Question"]=> array(5) { ["id"]=> > > > string(1) "2" ["question"]=> string(25) "Why won't you use > > > CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) > > > "2008-02-11 22:22:06" ["modified"]=> string(19) "2008-02-11 > > > 22:22:06" } } } > > > > On Dec 8, 8:35 am, thatsgreat2345 <[EMAIL PROTECTED]> wrote: > > > > > recursive = 'all'? Should be set to an > > > > integerhttp://book.cakephp.org/view/439/recursive > > > > > On Dec 7, 7:19 pm, Tanay <[EMAIL PROTECTED]> wrote: > > > > > > i have done that.. > > > > > here is my full questions_controller.php > > > > > > > > > > class QuestionsController extends AppController { > > > > > var $name = 'Questions'; > > > > > function home() { > > > > > $this->Question->recursive = 'all'; > > > > > $this->set('questions', $this->Question->find('all')); > > > > > } > > > > > function show( $id = null) { > > > > > if (!$id) { > > > > > $this->Session->setFlash('Invalid Question.'); > > > > > $this->redirect(array('action'=>'home')); > > > > > } > > > > > $this->set('question', $this->Question->read(null, $id)); > > > > > } > > > > > } > > > > > ?> > > > > > > === > > > > > > On Dec 8, 12:10 am, Rob <[EMAIL PROTECTED]> wrote: > > > > > > > Well based on your post, you are not getting the related model, and > > > > > > it > > > > > > appears you've only done a find on the Questions without setting > > > > > > recursive in your find('all'), try this: > > > > > > > $this->set('questions', $this->Question->find('all', array > > > > > > ('recursive' => 1))); > > > > > > > On Dec 7, 9:55 am, Tanay <[EMAIL PROTECTED]> wrote: > > > > > > > > MODEL answers.php > > > > > > > > > > > > > > class Answer extends AppModel { > > > > > > > var $name = 'Answer'; > > > > > > > var $belongsTo = array( > > > > > > > 'Question' => array( > > > > > > > 'className' => 'Question' > > > > > > > ) > > > > > > > ); > > > > > > > } > > > > > > > ?> > > > > > > > > Model questions.php > > > > > > > > > > > > > > class Question extends AppModel { > > > > > > > var $name = 'Question'; > > > > > > > var $hasMany = array( > > > > > > > 'Answer' => array( > > > > > > > '
Re: ORM, fetching related rows of corresponding model: undefined index..
no sight of 'answers' still On Dec 8, 4:10 pm, Tanay <[EMAIL PROTECTED]> wrote: > i changed the value to 2, > still the var_ dump is like this: > > array(2) { [0]=> array(1) { ["Question"]=> array(5) { ["id"]=> string > (1) "1" ["question"]=> string(22) "Why do you use > CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) > "2008-02-11 22:19:04" ["modified"]=> string(19) "2008-02-11 > 22:19:04" } } [1]=> array(1) { ["Question"]=> array(5) { ["id"]=> > string(1) "2" ["question"]=> string(25) "Why won't you use > CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) > "2008-02-11 22:22:06" ["modified"]=> string(19) "2008-02-11 > 22:22:06" } } } > > On Dec 8, 8:35 am, thatsgreat2345 <[EMAIL PROTECTED]> wrote: > > > recursive = 'all'? Should be set to an > > integerhttp://book.cakephp.org/view/439/recursive > > > On Dec 7, 7:19 pm, Tanay <[EMAIL PROTECTED]> wrote: > > > > i have done that.. > > > here is my full questions_controller.php > > > > > > class QuestionsController extends AppController { > > > var $name = 'Questions'; > > > function home() { > > > $this->Question->recursive = 'all'; > > > $this->set('questions', $this->Question->find('all')); > > > } > > > function show( $id = null) { > > > if (!$id) { > > > $this->Session->setFlash('Invalid Question.'); > > > $this->redirect(array('action'=>'home')); > > > } > > > $this->set('question', $this->Question->read(null, $id)); > > > } > > > } > > > ?> > > > > === > > > > On Dec 8, 12:10 am, Rob <[EMAIL PROTECTED]> wrote: > > > > > Well based on your post, you are not getting the related model, and it > > > > appears you've only done a find on the Questions without setting > > > > recursive in your find('all'), try this: > > > > > $this->set('questions', $this->Question->find('all', array > > > > ('recursive' => 1))); > > > > > On Dec 7, 9:55 am, Tanay <[EMAIL PROTECTED]> wrote: > > > > > > MODEL answers.php > > > > > > > > > > class Answer extends AppModel { > > > > > var $name = 'Answer'; > > > > > var $belongsTo = array( > > > > > 'Question' => array( > > > > > 'className' => 'Question' > > > > > ) > > > > > ); > > > > > } > > > > > ?> > > > > > > Model questions.php > > > > > > > > > > class Question extends AppModel { > > > > > var $name = 'Question'; > > > > > var $hasMany = array( > > > > > 'Answer' => array( > > > > > 'className' => 'Answer' > > > > > ) > > > > > ); > > > > > } > > > > > ?> > > > > > > === > > > > > > On Dec 7, 11:00 am, thatsgreat2345 <[EMAIL PROTECTED]> wrote: > > > > > > > Post your model code so we can see if you are doing your > > > > > > associations > > > > > > correctly, or if they are spelled correctly. > > > > > > > On Dec 6, 9:50 pm, Tanay <[EMAIL PROTECTED]> wrote: > > > > > > > > it seems no relationships are working with my cakephp. > > > > > > > has it got anything to do with my version of php5? > > > > > > > > i have got struck at this for a long time. > > > > > > > help will be very greatly appreciated. > > > > > > > > here is the var_dump of $questions as seen in home.ctp > > > > > > > array(2) { [0]=> array(1) { ["Question"]=> array(
Re: ORM, fetching related rows of corresponding model: undefined index..
i changed the value to 2, still the var_ dump is like this: array(2) { [0]=> array(1) { ["Question"]=> array(5) { ["id"]=> string (1) "1" ["question"]=> string(22) "Why do you use CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) "2008-02-11 22:19:04" ["modified"]=> string(19) "2008-02-11 22:19:04" } } [1]=> array(1) { ["Question"]=> array(5) { ["id"]=> string(1) "2" ["question"]=> string(25) "Why won't you use CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) "2008-02-11 22:22:06" ["modified"]=> string(19) "2008-02-11 22:22:06" } } } On Dec 8, 8:35 am, thatsgreat2345 <[EMAIL PROTECTED]> wrote: > recursive = 'all'? Should be set to an > integerhttp://book.cakephp.org/view/439/recursive > > On Dec 7, 7:19 pm, Tanay <[EMAIL PROTECTED]> wrote: > > > i have done that.. > > here is my full questions_controller.php > > > > class QuestionsController extends AppController { > > var $name = 'Questions'; > > function home() { > > $this->Question->recursive = 'all'; > > $this->set('questions', $this->Question->find('all')); > > } > > function show( $id = null) { > > if (!$id) { > > $this->Session->setFlash('Invalid Question.'); > > $this->redirect(array('action'=>'home')); > > } > > $this->set('question', $this->Question->read(null, $id)); > > } > > } > > ?> > > > === > > > On Dec 8, 12:10 am, Rob <[EMAIL PROTECTED]> wrote: > > > > Well based on your post, you are not getting the related model, and it > > > appears you've only done a find on the Questions without setting > > > recursive in your find('all'), try this: > > > > $this->set('questions', $this->Question->find('all', array > > > ('recursive' => 1))); > > > > On Dec 7, 9:55 am, Tanay <[EMAIL PROTECTED]> wrote: > > > > > MODEL answers.php > > > > > > > > class Answer extends AppModel { > > > > var $name = 'Answer'; > > > > var $belongsTo = array( > > > > 'Question' => array( > > > > 'className' => 'Question' > > > > ) > > > > ); > > > > } > > > > ?> > > > > > Model questions.php > > > > > > > > class Question extends AppModel { > > > > var $name = 'Question'; > > > > var $hasMany = array( > > > > 'Answer' => array( > > > > 'className' => 'Answer' > > > > ) > > > > ); > > > > } > > > > ?> > > > > > === > > > > > On Dec 7, 11:00 am, thatsgreat2345 <[EMAIL PROTECTED]> wrote: > > > > > > Post your model code so we can see if you are doing your associations > > > > > correctly, or if they are spelled correctly. > > > > > > On Dec 6, 9:50 pm, Tanay <[EMAIL PROTECTED]> wrote: > > > > > > > it seems no relationships are working with my cakephp. > > > > > > has it got anything to do with my version of php5? > > > > > > > i have got struck at this for a long time. > > > > > > help will be very greatly appreciated. > > > > > > > here is the var_dump of $questions as seen in home.ctp > > > > > > array(2) { [0]=> array(1) { ["Question"]=> array(5) { ["id"]=> > > > > > > string > > > > > > (1) "1" ["question"]=> string(22) "Why do you use > > > > > > CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) > > > > > > "2008-02-11 22:19:04" ["modified"]=> string(19) "2008-02-11 > > > > > > 22:19:04" } } [1]=> array(1) { [&
Re: ORM, fetching related rows of corresponding model: undefined index..
i have done that.. here is my full questions_controller.php Question->recursive = 'all'; $this->set('questions', $this->Question->find('all')); } function show( $id = null) { if (!$id) { $this->Session->setFlash('Invalid Question.'); $this->redirect(array('action'=>'home')); } $this->set('question', $this->Question->read(null, $id)); } } ?> === On Dec 8, 12:10 am, Rob <[EMAIL PROTECTED]> wrote: > Well based on your post, you are not getting the related model, and it > appears you've only done a find on the Questions without setting > recursive in your find('all'), try this: > > $this->set('questions', $this->Question->find('all', array > ('recursive' => 1))); > > On Dec 7, 9:55 am, Tanay <[EMAIL PROTECTED]> wrote: > > > > > MODEL answers.php > > > > class Answer extends AppModel { > > var $name = 'Answer'; > > var $belongsTo = array( > > 'Question' => array( > > 'className' => 'Question' > > ) > > ); > > } > > ?> > > > Model questions.php > > > > class Question extends AppModel { > > var $name = 'Question'; > > var $hasMany = array( > > 'Answer' => array( > > 'className' => 'Answer' > > ) > > ); > > } > > ?> > > > === > > > On Dec 7, 11:00 am, thatsgreat2345 <[EMAIL PROTECTED]> wrote: > > > > Post your model code so we can see if you are doing your associations > > > correctly, or if they are spelled correctly. > > > > On Dec 6, 9:50 pm, Tanay <[EMAIL PROTECTED]> wrote: > > > > > it seems no relationships are working with my cakephp. > > > > has it got anything to do with my version of php5? > > > > > i have got struck at this for a long time. > > > > help will be very greatly appreciated. > > > > > here is the var_dump of $questions as seen in home.ctp > > > > array(2) { [0]=> array(1) { ["Question"]=> array(5) { ["id"]=> string > > > > (1) "1" ["question"]=> string(22) "Why do you use > > > > CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) > > > > "2008-02-11 22:19:04" ["modified"]=> string(19) "2008-02-11 > > > > 22:19:04" } } [1]=> array(1) { ["Question"]=> array(5) { ["id"]=> > > > > string(1) "2" ["question"]=> string(25) "Why won't you use > > > > CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) > > > > "2008-02-11 22:22:06" ["modified"]=> string(19) "2008-02-11 > > > > 22:22:06" } } } > > > > > coresponding queries sql dump is > > > > DESCRIBE `questions` > > > > SELECT `Question`.`id`, `Question`.`question`, > > > > `Question`.`questioner`, `Question`.`created`, `Question`.`modified` > > > > FROM `questions` AS `Question` WHERE 1 = 1 > > > > > On Dec 7, 1:47 am, thatsgreat2345 <[EMAIL PROTECTED]> wrote: > > > > > > I see you are using the Packt Publishing book, ensure that your model > > > > > relations aren't misspelled or anything else it won't load the answers > > > > > and thus won't exist, in the controller do a debug on the find, that > > > > > or in the view do a pr($questions) before the foreach this will > > > > > display the array and see what exactly what is in the array. > > > > > > On Dec 6, 9:40 am, Tanay <[EMAIL PROTECTED]> wrote: > > > > > > > Tanay wrote: > > > > > > > i have two dbs questions , and answers.. > > > > > > > > corresponding models > > > > > > > > questions has many answers > > > > > > > answers belogns to questions > > > > > > > > in questions_controller, i have this home function > > > > > > > function home() { > > > > > >
Re: ORM, fetching related rows of corresponding model: undefined index..
MODEL answers.php array( 'className'=> 'Question' ) ); } ?> Model questions.php array( 'className' => 'Answer' ) ); } ?> === On Dec 7, 11:00 am, thatsgreat2345 <[EMAIL PROTECTED]> wrote: > Post your model code so we can see if you are doing your associations > correctly, or if they are spelled correctly. > > On Dec 6, 9:50 pm, Tanay <[EMAIL PROTECTED]> wrote: > > > > > it seems no relationships are working with my cakephp. > > has it got anything to do with my version of php5? > > > i have got struck at this for a long time. > > help will be very greatly appreciated. > > > here is the var_dump of $questions as seen in home.ctp > > array(2) { [0]=> array(1) { ["Question"]=> array(5) { ["id"]=> string > > (1) "1" ["question"]=> string(22) "Why do you use > > CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) > > "2008-02-11 22:19:04" ["modified"]=> string(19) "2008-02-11 > > 22:19:04" } } [1]=> array(1) { ["Question"]=> array(5) { ["id"]=> > > string(1) "2" ["question"]=> string(25) "Why won't you use > > CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) > > "2008-02-11 22:22:06" ["modified"]=> string(19) "2008-02-11 > > 22:22:06" } } } > > > coresponding queries sql dump is > > DESCRIBE `questions` > > SELECT `Question`.`id`, `Question`.`question`, > > `Question`.`questioner`, `Question`.`created`, `Question`.`modified` > > FROM `questions` AS `Question` WHERE 1 = 1 > > > On Dec 7, 1:47 am, thatsgreat2345 <[EMAIL PROTECTED]> wrote: > > > > I see you are using the Packt Publishing book, ensure that your model > > > relations aren't misspelled or anything else it won't load the answers > > > and thus won't exist, in the controller do a debug on the find, that > > > or in the view do a pr($questions) before the foreach this will > > > display the array and see what exactly what is in the array. > > > > On Dec 6, 9:40 am, Tanay <[EMAIL PROTECTED]> wrote: > > > > > Tanay wrote: > > > > > i have two dbs questions , and answers.. > > > > > > corresponding models > > > > > > questions has many answers > > > > > answers belogns to questions > > > > > > in questions_controller, i have this home function > > > > > function home() { > > > > > $this->Question->recursive = 1; > > > > > $this->set('questions', $this->Question->find('all')); > > > > > } > > > > > > in my home.ctp, i tried to show the corresponding answers using the > > > > > code below > > > > > i took a question from an array of questions using foreach > > > > > foreach question, $question['Answer'] is expected to give array of > > > > > answers, but it says Undefined index: Answer > > > > > THAT LIne is marked in code below > > > > > > home.ctp: > > > > > > > > > > > No Questions yet. Be the first one to > > > > > post a Question! > > > > > > > > > > > > > > > > > > > > > > > > ?> > > > > > > > > > > link($question['Question']['question'] > > > > > .'?', array('action' => 'show', $question['Question']['id']))); ?> > > > > > > > > > $answer_count = count($question > > > > > ['Answer']); // <<-ERROR HERE > > > > > if(!$answer_count) > > > > > e("(no answers yet)"); > > > > > else if($answer_count == 1) > > > > > e("(1 answer)"); > > > > > else > > > > > e("(".$answer_count." answers)"); > > > > > ?> > > > > > > > > > > > > > > > > > > > > > > > > > > the above code is a part of project in book CakePHP application > > > > > Development, > > > > > the code is same as in book > > > > > is it due to some different version of cakephp that author used? > > > > > i use latest 1.2 version > > > > > . . . . . . > > > > Still the same. But now it says > > > > The new variable name $question['question']['answer'] is undefined > > > > index. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: ORM, fetching related rows of corresponding model: undefined index..
it seems no relationships are working with my cakephp. has it got anything to do with my version of php5? i have got struck at this for a long time. help will be very greatly appreciated. here is the var_dump of $questions as seen in home.ctp array(2) { [0]=> array(1) { ["Question"]=> array(5) { ["id"]=> string (1) "1" ["question"]=> string(22) "Why do you use CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) "2008-02-11 22:19:04" ["modified"]=> string(19) "2008-02-11 22:19:04" } } [1]=> array(1) { ["Question"]=> array(5) { ["id"]=> string(1) "2" ["question"]=> string(25) "Why won't you use CakePHP" ["questioner"]=> string(5) "Ahsan" ["created"]=> string(19) "2008-02-11 22:22:06" ["modified"]=> string(19) "2008-02-11 22:22:06" } } } coresponding queries sql dump is DESCRIBE `questions` SELECT `Question`.`id`, `Question`.`question`, `Question`.`questioner`, `Question`.`created`, `Question`.`modified` FROM `questions` AS `Question` WHERE 1 = 1 On Dec 7, 1:47 am, thatsgreat2345 <[EMAIL PROTECTED]> wrote: > I see you are using the Packt Publishing book, ensure that your model > relations aren't misspelled or anything else it won't load the answers > and thus won't exist, in the controller do a debug on the find, that > or in the view do a pr($questions) before the foreach this will > display the array and see what exactly what is in the array. > > On Dec 6, 9:40 am, Tanay <[EMAIL PROTECTED]> wrote: > > > Tanay wrote: > > > i have two dbs questions , and answers.. > > > > corresponding models > > > > questions has many answers > > > answers belogns to questions > > > > in questions_controller, i have this home function > > > function home() { > > > $this->Question->recursive = 1; > > > $this->set('questions', $this->Question->find('all')); > > > } > > > > in my home.ctp, i tried to show the corresponding answers using the > > > code below > > > i took a question from an array of questions using foreach > > > foreach question, $question['Answer'] is expected to give array of > > > answers, but it says Undefined index: Answer > > > THAT LIne is marked in code below > > > > home.ctp: > > > > > > > No Questions yet. Be the first one to > > > post a Question! > > > > > > > > > > > > > > ?> > > > > > > link($question['Question']['question'] > > > .'?', array('action' => 'show', $question['Question']['id']))); ?> > > > > > $answer_count = count($question > > > ['Answer']); // <<-ERROR HERE > > > if(!$answer_count) > > > e("(no answers yet)"); > > > else if($answer_count == 1) > > > e("(1 answer)"); > > > else > > > e("(".$answer_count." answers)"); > > > ?> > > > > > > > > > > > > > > > > the above code is a part of project in book CakePHP application > > > Development, > > > the code is same as in book > > > is it due to some different version of cakephp that author used? > > > i use latest 1.2 version > > > . . . . . . > > Still the same. But now it says > > The new variable name $question['question']['answer'] is undefined > > index. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: ORM, fetching related rows of corresponding model: undefined index..
Tanay wrote: > i have two dbs questions , and answers.. > > corresponding models > > questions has many answers > answers belogns to questions > > in questions_controller, i have this home function > function home() { > $this->Question->recursive = 1; > $this->set('questions', $this->Question->find('all')); >} > > > in my home.ctp, i tried to show the corresponding answers using the > code below > i took a question from an array of questions using foreach > foreach question, $question['Answer'] is expected to give array of > answers, but it says Undefined index: Answer > THAT LIne is marked in code below > > home.ctp: > > >No Questions yet. Be the first one to > post a Question! > > > > ?> > > link($question['Question']['question'] > .'?', array('action' => 'show', $question['Question']['id']))); ?> > $answer_count = count($question > ['Answer']); // <<-ERROR HERE > if(!$answer_count) >e("(no answers yet)"); > else if($answer_count == 1) >e("(1 answer)"); > else >e("(".$answer_count." answers)"); > ?> > > > > > > the above code is a part of project in book CakePHP application > Development, > the code is same as in book > is it due to some different version of cakephp that author used? > i use latest 1.2 version . . . . . . Still the same. But now it says The new variable name $question['question']['answer'] is undefined index. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
ORM, fetching related rows of corresponding model: undefined index..
i have two dbs questions , and answers.. corresponding models questions has many answers answers belogns to questions in questions_controller, i have this home function function home() { $this->Question->recursive = 1; $this->set('questions', $this->Question->find('all')); } in my home.ctp, i tried to show the corresponding answers using the code below i took a question from an array of questions using foreach foreach question, $question['Answer'] is expected to give array of answers, but it says Undefined index: Answer THAT LIne is marked in code below home.ctp: No Questions yet. Be the first one to post a Question! link($question['Question']['question'] .'?', array('action' => 'show', $question['Question']['id']))); ?> the above code is a part of project in book CakePHP application Development, the code is same as in book is it due to some different version of cakephp that author used? i use latest 1.2 version --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Newbie facing an error
Warning: file_put_contents(/f1/content/cakeme/public/myapp/app/tmp/ cache/models/default_cake_list) [function.file-put-contents]: failed to open stream: Permission denied in /f1/content/cakeme/public/myapp/ cake/basics.php on line 936 Warning: file_put_contents(/f1/content/cakeme/public/myapp/app/tmp/ cache/models/default_items) [function.file-put-contents]: failed to open stream: Permission denied in /f1/content/cakeme/public/myapp/cake/ basics.php on line 936 any help? getting error while trying to view the default scaffolding view. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---