Home  >  Article  >  Backend Development  >  第一回用CI框架写MODEL层

第一回用CI框架写MODEL层

WBOY
WBOYOriginal
2016-06-13 12:58:051044browse

第一次用CI框架写MODEL层
第一次用CI框架写model,不知道对不对,麻烦大家看一下...谢谢啦
class Article_model extends CI_Model {
function __construct(){
parent::__construct();
$this->load->model('modelDB');
}
function select_article($time,$name,$lable,$type,$details,$URL,$img){
$sql=$this->db->where('articleType',$type);
$art=$this->get('article');
//$q="select * from article where ";
if($sql->num_rows >0){
return $art;
}else{
return false;
}
}
function insert_article($time,$name,$lable,$type,$details,$URL,$img){
$data=array('articleName'=>$name,'articleTime'=>$time,'articleLable'=>$lable,'articleType'=>$type,'articleDetails'=>$details,'articleURL'=>$URL,'articleImg'=>$img);
$sql=$this->db->insert('article',$data);
if($sql->num_rows >0){
return $sql->row();
}else{
return false;
}
}
function update_article($id,$time,$name,$lable,$type,$details,$URL,$img){
$date=array('articleName'=>$name,'articleTime'=>$time,'articleLable'=>$lable,'articleType'=>$type,'articleDetails'=>$details,'articleURL'=>$URL,'articleImg'=>$img);
$q=$this->db->where('arrticlId',$id)->update('article',$date);
}
}
?>
------解决方案--------------------
你运行哈就知道对不对了嘛
还有你modelDB下面都没看到用为啥要load进来

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