Adderror Could Not Be Converted To String

I’m getting a recoverable error when trying to throw a custom error message. I’m trying to call this to throw the error:


$this->addError($attribute, 'The VIP balance is too low!');

The error message is:

"Object of class stdClass could not be converted to string"


D:\Dropbox\Web\yii\framework\db\schema\CDbCommandBuilder.php(379)


367             return $sql;

368     }

369 

370     /**

371      * Alters the SQL to apply WHERE clause.

372      * @param string $sql the SQL statement without WHERE clause

373      * @param string $condition the WHERE clause (without WHERE keyword)

374      * @return string the altered SQL statement

375      */

376     public function applyCondition($sql,$condition)

377     {

378         if($condition!='')

379             return $sql.' WHERE '.$condition;

380         else

381             return $sql;

382     }

383 

384     /**

385      * Alters the SQL to apply ORDER BY.

386      * @param string $sql SQL statement without ORDER BY.

387      * @param string $orderBy column ordering

388      * @return string modified SQL applied with ORDER BY.

389      */

390     public function applyOrder($sql,$orderBy)

391     {

Any idea what’s causing this error or what could be causing this error? My attribute value is a valid field and is a string. Thanks!

[size=“2”][color="#1c2837"]stdClass is an empty php class. Usually means that $this isn’t an object. Post your code?[/color][/size]

I think $attribute is an object without __toString() method. Implement it.

Yes, I bet your $attribute variable holds an object, not a string