CDbException

CDbCommand falló al ejecutar la sentencia SQL: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY vistas DESC LIMIT 5' at line 1. The SQL statement executed was: SELECT * FROM `tbl_publicaciones` `t` WHERE activo = 1 AND id_categoria = ORDER BY vistas DESC LIMIT 5

/data/public_html/PHPServer/yii-master/framework/db/CDbCommand.php(528)

516             return $result;
517         }
518         catch(Exception $e)
519         {
520             if($this->_connection->enableProfiling)
521                 Yii::endProfile('system.db.CDbCommand.query('.$this->getText().$par.')','system.db.CDbCommand.query');
522             $errorInfo = $e instanceof PDOException ? $e->errorInfo : null;
523             $message = $e->getMessage();
524             Yii::log(Yii::t('yii','CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.',
525                 array('{method}'=>$method, '{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
526             if(YII_DEBUG)
527                 $message .= '. The SQL statement executed was: '.$this->getText().$par;
528             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
529                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
530         }
531     }
532 
533     /**
534      * Builds a SQL SELECT statement from the given query specification.
535      * @param array $query the query specification in name-value pairs. The following
536      * query options are supported: {@link select}, {@link distinct}, {@link from},
537      * {@link where}, {@link join}, {@link group}, {@link having}, {@link order},
538      * {@link limit}, {@link offset} and {@link union}.
539      * @return string the SQL statement
540      * @since 1.1.6

Stack Trace

#3
+
 /data/public_html/PHPServer/LN_MID/protected/controllers/SiteController.php(105): CActiveRecord->findAll(array("condition" => "activo = 1 AND id_categoria = ", "order" => "vistas DESC", "limit" => 5))
100     }    
101 
102     public function actionPublicacion($id){
103 
104         $model = Publicaciones::model()->findByPk($id);
105         $modelVisitas = Publicaciones::model()->findAll(array('condition'=>'activo = 1 AND id_categoria = '.$model->idCategoria->id, 'order'=>'vistas DESC', 'limit'=>5));
106         $modelRecientes = Publicaciones::model()->findAll(array('condition'=>'activo = 1 AND id_categoria = '.$model->idCategoria->id, 'order'=>'log DESC', 'limit'=>5));
107         
108         $model->vistas = $model->vistas + 1;
109         $model->saveAttributes(array('vistas'=>$model->vistas));
110         
#13
+
 /data/public_html/PHPServer/LN_MID/index.php(13): CApplication->run()
08 defined('YII_DEBUG') or define('YII_DEBUG',true);
09 // specify how many levels of call stack should be shown in each log message
10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
11 
12 require_once($yii);
13 Yii::createWebApplication($config)->run();
14 
2024-03-29 02:19:10 Apache/2.4.25 (Debian) Yii Framework/1.1.12