Cakephp Function in mode not executing

Posted by Rixius on Stack Overflow See other posts from Stack Overflow or by Rixius
Published on 2010-04-12T21:04:52Z Indexed on 2010/04/12 22:32 UTC
Read the original article Hit count: 434

Filed under:
|
|
|

I have a function in my Comic Model as such:

<?php

class Comic extends AppModel
{
    var $name = "Comic";
    // Methods for retriving information.
    function testFunc(){
        $mr = $this->find('all');
        return $mr;
    }
}
?>

And I am calling it in my controller as such:

<?php
class ComicController extends AppController
{
   var $name = "Comic";
   var $uses = array('Comic');
   function index()
   {
  }
  function view($q)
  {
    $this->set('array',$this->Comic->testFunc());
  }
}
?>

When I try to load up the page; I get the following error:

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 'testFunc' at line 1 [CORE/cake/libs/model/datasources/dbo_source.php, line 525] Query: testFunc

And the SQL dump looks like this:

(default) 2 queries took 1 ms
Nr Query Error Affected Num. rows Took (ms)
1 DESCRIBE comics 10 10 1
2 testFunc 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 'testFunc' at line 1 0

So it looks like, instead of running the testFunc() function, it is trying to run a query of "testFunc" and failing...

© Stack Overflow or respective owner

Related posts about php

Related posts about cakephp