Home  >  Article  >  Backend Development  >  CI框架代码转换

CI框架代码转换

WBOY
WBOYOriginal
2016-06-23 13:56:031042browse

$array = array();while($row = mysql_fetch_array($result,MYSQL_ASSOC)){    $key = date('Y年m月d日',$row['time']);    $array[$key][]=$row;}

请问这段代码怎么转为CI框架的?


回复讨论(解决方案)

$array = array();
$query = $this->db->query("要执行的 SQL");
foreach ($query->result_array() as $row)
    $key = date('Y年m月d日',$row['time']);
    $array[$key][]=$row;
}

$array = array();
$query = $this->db->query("要执行的 SQL");
foreach ($query->result_array() as $row)
    $key = date('Y年m月d日',$row['time']);
    $array[$key][]=$row;
}


这样是把所有数据循环出来了,请问怎么只循环出从今天开始3天内的信息呢

判断啊,取服务器当前时间就是今天时间了,+1day,+2day,$row['time']等于就装数组$array

判断啊,取服务器当前时间就是今天时间了,+1day,+2day,$row['time']等于就装数组$array


新手啊,求代码

//要执行的 SQL
$sql = "se;lect * from tb where ctime == time())";
$query = $this->db->query("要执行的 SQL");

//要执行的 SQL
$sql = "se;lect * from tb where ctime == time())";
$query = $this->db->query("要执行的 SQL");


已经解决了,不过还是多谢你了!
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn