$results = Yii::app()->db
->createCommand("select * from tbl where cmail='$mail' and ename='$ename'")
->queyAll();
Yii: Write sql query find duplicate rows in database
Frage
I have a sql query and unable to figure out how to write it in yii
$con=mysqli_connect('localhost','user','pwd','db_name');
$check = mysqli_query($con,"select * from tbl where cmail='$mail' and ename='$ename' ");
if(mysqli_num_rows($check)>0)
{
//do nothing;
}
else
{
//insert row to db
}
I have tried doing it in the following way, unable to figure out my mistake
$cmd1 = Yii::app()->db->createCommand("select * from tbl where cmail='$mail' and ename='$ename' ");
$cmd1->execute();
if(mysqli_num_rows($cmd1)>0)
{
//...
}
else
{
//...
}
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow