2014-03-03 13 views
1
public function getGet($nid) 
     { 
      $sensor = $this->findBySql("select * from tbl_sensor where stype=4 and nid=$nid order by timestamp desc limit 10;"); 

     if ($sensor == NULL) 
     return "NULL"; 
     return $sensor->sdata; 
     } 
+0

var_dump($ sensor);'? –

+0

字符串(1)「0」字符串(1)「0」字符串(1)「0」字符串(3)「473」 – sanjeev

+0

您是否在模型中使用此代碼? –

回答

0

試試這個代碼。

echo "select * from tbl_sensor where stype=4 and nid=$nid order by timestamp desc limit 10"; 
$res= Yii::app()->db->createCommand("select * from tbl_sensor where stype=4 and nid=$nid order by timestamp desc limit 10")->queryAll(); 

//print_r($res); // will return array of result. 
// to check query, print the query executed. 

return $res; 
+0

庫馬爾,還沒有得到結果, – sanjeev

+0

你要回答什麼? –

+0

throw new CDbException(Yii :: t('yii','CDbCommand failed to execute the SQL statement:{error}', – sanjeev

相關問題