hi , i am not able to get last 10 element in yii , using findby sql

StackOverflow https://stackoverflow.com/questions/22141436

  •  19-10-2022
  •  | 
  •  

문제

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

해결책

try this code.

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top