First, use the CI framework to write the MODEL layer

Source: Internet
Author: User
The first time I used the CI framework to write the MODEL layer, I used the CI framework to write the model for the first time. I don't know if it is correct. please take a look at it... thanks & lt ;? Phpclass & nbsp; Article_model & nbsp; extends & nbsp; CI_Model & nbsp; {function & nbsp ;__ construct () writes the MODEL layer using the CI framework for the first time
I used the CI framework to write the model for the first time. I don't know if it is correct. please take a look... thank you.
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 );
}
}
?>
------ Solution --------------------
If you run the command, you will know that it is correct.
And you didn't see it below modelDB. why should I load it in?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.