method call another method by that name? This error usually occurs
because a model method cannot be found (regardless of it being
principal model or not). eg.
Are you certain that you have the correct spelling and case (eg. not
threadedPages)?
On Thu, Sep 2, 2010 at 5:35 AM, ashok.b <email2ash@gmail.com> wrote:
> I have two tables, Pages and Posts that are in HABTM and are joined
> using pages_posts join table.
>
> My Page model along with the HABTM definition contains a function..
>
> class Page extends AppModel
> {
> var $name = "Page";
> ......
> ......
> function callthis()
> {
> return $this->find('all');;
> }
> }
>
> From my Posts controller, I'm trying to call that function..
>
> class PostsController extends AppController
> {
> ....
> ....
> function index()
> {
> $returned = $this->Post->Page->callthis();
> }
> }
>
> This results in
>
> Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
> check the manual that corresponds to your MySQL server version for the
> right syntax to use near 'threadedpages' at line 1 [CORE/cake/libs/
> model/datasources/dbo_source.php, line 681]
>
> Further Debug output:
>
> Code
>
> $out = null;
> if ($error) {
> trigger_error('<span style="color:Red;text-
> align:left"><b>' . __('SQL Error:', true) . "</b> {$this->error}</
> span>", E_USER_WARNING);
>
> Context
>
> $sql = "threadedpages"
> $error = "1064: You have an error in your SQL syntax; check the
> manual that corresponds to your MySQL server version for the right
> syntax to use near 'threadedpages' at line 1"
> $out = null
>
> Calls
>
> DboSource::showQuery() - CORE/cake/libs/model/datasources/
> dbo_source.php, line 681
> DboSource::execute() - CORE/cake/libs/model/datasources/
> dbo_source.php, line 266
> DboSource::fetchAll() - CORE/cake/libs/model/datasources/
> dbo_source.php, line 410
> DboSource::query() - CORE/cake/libs/model/datasources/dbo_source.php,
> line 364
> Model::call__() - CORE/cake/libs/model/model.php, line 502
> Overloadable::__call() - CORE/cake/libs/overloadable_php5.php, line 50
> AppModel::threadedpages() - [internal], line ??
> PostsController::admin_index() - CORE/plugins/cakey/controllers/
> posts_controller.php, line 11
> Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
> Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
> [main] - APP/webroot/index.php, line 83
>
> Calling a associated model function should be possible in CakePHP
> right? If we checkout http://book.cakephp.org/view/1044/hasAndBelongsToMany-HABTM,
> We can see that
>
> $this->Recipe->Tag->find('all',
> array('conditions'=>array('Tag.name'=>'Dessert')));
>
> When find() function of Tag model can be called from associated
> Recipes controller, Why can't I call callthis() function of Page model
> from associated Posts controller?
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
>
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment