FORUMS CLOSED DUE TO SPAM. YOU STILL CAN ADD POST!

Fatal error: Call to a member function execute() on a non-object in ............/framework/Framework.php on line 551

Feed 13 posts, 6 voices

Avatar
1 posts

Localy everything works great (PHP Version 5.2.3-1ubuntu6)

however on my production (PHP Version 5.1.6) machine I get:

Fatal error: Call to a member function execute() on a non-object in ............/framework/Framework.php on line 551 It relates to:

$stmt = self::$CONN->prepare($sql); $stmt->execute($values);

As a matter of fact, some querries were properly executed. No idea why because, PDO is compiled in.

PLEASE HELP Pete

 
Avatar
541 posts

I need more informations!

Where did you get this error (administration or public site), which page, in snippet section, in the page list, page edit, layout ...

What version of Frog CMS do you use ?

do you use PDO or you use ... all informations you can give will help to answer your problem.

 
Avatar
5 posts

Actualy this has nothing to do with the CMS, which is great by the way and we use it as well.

I am getting this error in the framework.php which we are employing in a current project. This has something to do with the Record class. Every controller methods that queries the database throws such message out and finishes without displaying view. What is interesting is that some queries go through and actualy are recorded in the database.

We never devoted that much time into figuring out how exactly the framework works, but know that we have to heres a question:

in config.php we create a new global variable $PDO_CONN index.php is calling Record::connection($PDO_CONN)

now every signle method of the Record class is static. I dont see anywhere in the code a declaration $r = new Record() $r->PDO_CONN = $PDO_CONN or alternatively $r->savePdo($PDO_CONN);

My knowledge of PHP is limited so maybe im wrong but how is it possible that calling Record::connection() preserves the state of the self::PDO_CONN in methods which are called later from uninstantioated class(called staticaly)

Cheers, Pete

 
Avatar
541 posts

Ho ok .. this is your sql query that is wrong ... the framework execute your query that's it !! , so the problem is not in the framework.

 
Avatar
541 posts

maybe I can add some tracking error there !!, but for now the framework doesn't track error

 
Avatar
5 posts

do you have any idea of what could be going wrong, or perhaps an idea for a quick fix? Id appreciate that.

i spent last two weeks working on a something that which works perfectly on my local machine, and I absolutely need it in production by tomorrow :)

 
Avatar
56 posts

Try running your query by hand as the same DB user you are having the Framework run it as. Also, ensure that the query you think you're running is indeed the same as the one you actually are executing. (For example, you may have a quoting issue in your "live" query, but not your "test" query.)

 
Avatar
5 posts

Alright now im sure this is PDO driver and mysql version related issue. Nothing todo with framework

 
Avatar
5 posts

More news, i think this has to do with $stmt->fetch and lack of the $stmt->closeCursor()

Heres an explanation of the problem http://www.inovaone.com/blog/?p=25

Ill post a solution if i get it working

 
Avatar
541 posts

Ho maybe I have something for you then .... try to set this after creating your pdo connection $PDO = new PDO(DB_DSN, DB_USER, DB_PASS);

write:

$PDO->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);

and thanks for the closeCursor(), I will look at this more in details

 
Avatar
5 posts

Thanks that was one of the first things i tried, but it did not help.

Anyhow I resolved the whole issue and Im still not sure were the problem was - but it has to do with the particular server setup.

By the way your framework ROCKS. Thanks!!!

Pete

 
Avatar
541 posts

I think if you can use it without any documentation this is a good thing !! :) if you have any problem or suggestion, we will do hour best !

 
Avatar
1 posts

I get a similar problem:

Fatal error: Call to a member function execute() on a non-object in /var/www/comercial/frog/app/backend/models/Page.php on line 222

So I go to line 222 and see this:

       $stmt->execute($values);

So the problem should be before that, so I insert a print() for the $sql:

   public static function maxPosition($parentID, $values=array())
    {
        $sql =  'SELECT IFNULL(MAX(position ), 1) '.
                                'FROM Page '.
                                'WHERE parent_id ='.$parentID;

         print($sql);

        $stmt = self::$__CONN__->prepare($sql);
        $stmt->execute($values);

        self::logQuery($sql);

        return (int) $stmt->fetchColumn();
    }

Then I check the output and try that SQL directly in mysql (from command line):

mysql> SELECT IFNULL(MAX(position ), 1) FROM Page WHERE parent_id =1;
ERROR 1146 (42S02): Table 'frog.Page' doesn't exist

show tables;
+--------------+
| Tables_in_frog  |
+--------------+
| page            |
| page_part       |
| page_tag        |
…
etc

so I rename “Page” to “page” that is a real table in the DB:

SELECT IFNULL(MAX(position ), 1) FROM page WHERE parent_id =1;
+---------------------+
| IFNULL(MAX(position ), 1) |
+---------------------+
|                         5 |
+---------------------+
1 row in set (0.02 sec)

The problem was in the SQL syntax so no $stmt variable was created (here no one check for return errors) and in line 222 the error was really clear:

Fatal error: Call to a member function execute() on a non-object

We can remark the non-object think here.

 
Avatar
1 posts

as someone whos non technical (i dont know php) is there a quick file overwrite i can do to fix this and if so does anyone have a file i can use :)

many thanks
mark