2017-03-08 37 views
0

低於控制器代碼中寫上下文中使用函數返回值顯示以下錯誤不能在yii2

不能在yii2

代碼中寫上下文中使用函數返回值: -

$sql = "select * from purchase_meta where status_manager=0 and po_id='p5' "; 
$sql1 = \app\models\PurchaseMeta::findBySql($sql)->all();  
if(count($sql1)=0){ 
    $model =new \app\models\PurchaseOrder(); 
    $model->purchase_status = 1 ; 
    if ($model->save()){ 
    echo "save"; 
    exit(); 
    }else { 
    print_r($model->getErrors()); 
    exit(); 
    } 
} 

我該如何解決這個問題?

回答

1

問題: -

if(count($sql1)=0) //is an assignment not a comparison 

更改爲: -

if(count($sql1)==0)