jaimerump
jaimerump

Reputation: 882

Catchable fatal error: Object could not be converted to string

In my Zend Framework application I'm getting this error:

Catchable fatal error: Object of class User could not be converted to string in /home/trengine/domains/completeset.us/application/models/User.php on line 121

Line 121 is the where clause in this mySql query:

$query = "SELECT first,
                         last,
                         email,
                         gender,
                         user_type,
                         country,
                         state,
                         province,
                         city,
                         DATE_FORMAT(birthday, '%m/%d/%Y') AS birthday,
                         facebook_id
                         FROM users
                         WHERE user_id = '{$this->id}'";

Upvotes: 0

Views: 6188

Answers (1)

Roger Thomas
Roger Thomas

Reputation: 695

Put this before you call the database:

var_dump($this->id);

This will show you what variable type you're dealing with. More than likely the id has been cast as an object somewhere along the lines.

Also, and my apologies in advance... but you should look into Zend DB Table Abstract and extend from it. You'll find it a lot easier down the road to perform any changes you need to make to your project.

Upvotes: 2

Related Questions