hi,
Is there a way to call mysql_query function, or other mysql functions from yii ?
thanks…
hi,
Is there a way to call mysql_query function, or other mysql functions from yii ?
thanks…
Yii uses PDO, so u can get pdo object from dbconnection.
Take a look this one: getPDo
maybe you mean like this
$connection=Yii::app()->db; // assuming you have configured a "db" connection
// If not, you may explicitly create a connection:
// $connection=new CDbConnection($dsn,$username,$password);
$sql = 'insert into table(id, name) values (:id, :name)';
$command=$connection->createCommand($sql);
$command->bindParam(":id",$id,PDO::PARAM_STR);
$command->bindParam(":name",$name,PDO::PARAM_STR);
$command->execute();
or
$sql1 = 'select name from table';
$dataReader=$connection->createCommand($sql1)->query();
$dataReader->bindColumn(1,$id_download);
while($dataReader->read()!==false){}
or
$criteria=new CDbCriteria;
$criteria->join = ' left outer JOIN admin ON t.id_admin = admin.id_admin ';
$criteria->compare('id',$this->id,true);
$criteria->compare('name',$this->name,true);
$criteria->condition = "id= ".$id;
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
also check this
sorry if it’s not what you ask about…
just want to help…
use this is
$conn = $this->getDbConnection();
$query = ‘select * from emp’;
$rows = $conn->createCommand($query)->query();
while(($row = $rows->read()) !== false)
{
echo $row[id].'-'.$row['name'];
}
query()
queryAll()
queryRow()
Hope this more useful to you.
Thanks
Pravin Gjara