一、

$connection = Yii::app()->db;  
$sql = "SELECT * FROM `project` ORDER BY id DESC";  
$command = $connection->createCommand($sql);  
$result = $command->queryAll();  
print_r($result);  

 

二、

$db = Yii::app()->db; //you have to define db connection in config/main.php  
$sql = "select sum(if(starttime>'09:00:00',1,0)) as late,  
  sum(if(endtime<'18:00:00',1,0)) as early           
from present where userid=:userid and date between :date_start and :date_end"  
$results = $db->createCommand($sql)->query(array(  
  ':userid' => 115,':date_start'=>'2009-12-1',':date_end'=>'2009-12-31',  
));  
foreach($results as $result){  
  echo $result['late']," and ",$result['early']," /n";

相关文章:

  • 2022-02-27
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
  • 2021-10-01
  • 2021-11-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2021-12-08
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案