query columns as Object


(Narkomanc) #1

i think its more php problem maybe, but if you know please help.

On my local machine all code is parsed without error, but on production server it’s get error, which i can see in yii log




[error] [system.db.CDbCommand] Error in querying SQL: SELECT Object id #59 FROM ... etc.



and that rises error such




[error] [exception.CDbException] exception

'CDbException' with message 'CDbCommand failed to execute the SQL

statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column

'Object' in 'field list'' in



you see SELECT here is columns list FROM …


(Narkomanc) #2

fixed… if you can explain why it breaks here


$criteria = new CDbCriteria(); 

$criteria->select = new CDbExpression('FLOOR(RAND() * '.$rowCount.') as offset');

but if i dont use CDbExpression class, than its ok


$criteria->select = 'FLOOR(RAND() * '.$rowCount.') as offset';

it was not designed for these kind of functions to include in sql query?


(Maurizio Domba Cerin) #3

take a look at the documentation for CDbExpression

http://www.yiiframew…i/CDbExpression

it’s mainly used for CActiveRecord attribute values…

EDIT: don’t know why but this editor inserts <b></b> inside this link… so the link is not working!!!


(Maurizio Domba Cerin) #4

take a look at the documentation for CDbExpression


http://www.yiiframework.com/doc/api/CDbExpression

it’s mainly used for CActiveRecord attribute values…