Buenas Tardes mi problema es Simple intento ejecutar una sentencia SQL y me da error, esta es la sentencia SQL:
SET @rownum = 0;
select rank from (SELECT usda_code
, @rownum:=@rownum+1 rank FROM user_data
order by usda_punctuation
desc, usda_level
desc, usda_code
asc) as ranking where usda_code=15
Como pueden ver declaro una variable SET @rownum = 0;
Y luego la Uso @rownum:=@rownum+1 rank.
Si ejecuto este SQL en mi consola funciona sin problema pero Yii me da el siguente error:
CDbException
Descripción
CDbCommand falló al ejecutar la sentencia SQL: SQLSTATE[HY000]: General error
Archivo Fuente:
C:\wamp\www\yii-1.1.0.r1700\framework\db\CDbCommand.php(375)
00363: }
00364:
00365: if($this->_connection->enableProfiling)
00366: Yii::endProfile(‘system.db.CDbCommand.query(’.$this->getText().’)’,‘system.db.CDbCommand.query’);
00367:
00368: return $result;
00369: }
00370: catch(Exception $e)
00371: {
00372: if($this->_connection->enableProfiling)
00373: Yii::endProfile(‘system.db.CDbCommand.query(’.$this->getText().’)’,‘system.db.CDbCommand.query’);
00374: Yii::log('Error in querying SQL: '.$this->getText().$par,CLogger::LEVEL_ERROR,‘system.db.CDbCommand’);
00375: throw new CDbException(Yii::t(‘yii’,‘CDbCommand failed to execute the SQL statement: {error}’,
00376: array(’{error}’=>$e->getMessage())));
00377: }
00378: }
00379: }
De ante mano Gracias por la colaboración.