문제

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
{
 //...
}
도움이 되었습니까?

해결책

$results = Yii::app()->db
    ->createCommand("select * from tbl where cmail='$mail' and ename='$ename'")
    ->queyAll();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top