Hi everyone, I’m new to Yii, so the Q is - when I execute queries this way, everything works fine:
$resutl = $this->conn->createCommand($sql)->query();
foreach ($result AS $row) {
echo $row['title'];
}
but when I try to do somthing like (DAO style):
$sql = "SELECT title, year_made FROM movies WHERE year_made=':ym'";
$command = $this->conn->createCommand($sql);
$command->bindParam(":ym", "2012", PDO::PARAM_STR);
$result = $command->query();
or (AR style):
$result = Movies::model()->find("m_id=:m_id", array(":m_id"=>27));
$result = Movies::model()->findByPk(24);
both examples didn’t work.
Model code:
class Movies extends CActiveRecord {
public static function model($className = __CLASS__) {
parent::model($className);
}
public function tableName() {
return 'movies';
}
}
Though, I know that the @Override of method tableName is needless, because table name is compatible to a class name of a Model.
PS db is configured well, table name is movies, also there is strange behaviour - code just crashs and exceptions or even errors didn`t occur. Sorry for my English.