KohanaORM operation tutorial (Kohana3.3)

Source: Internet
Author: User
Tags kohana
Kohana is undoubtedly my favorite framework. it is lightweight and has more modules and ORM than CI. I am honored to use it in the next project. I have read the KohanaORM operation tutorial, posted. Step 1: You need

Kohana is undoubtedly my favorite framework. it is lightweight and has more modules and ORM than CI. it is a great honor to use it in the next project, after reading the Kohana ORM operation tutorial, I posted it.
Step 1: enable the orm function module in application/bootstap. php.

Kohana: modules (array (

'Orm '=> MODPATH. 'orm', // Object Relationship Mapping

));


Step 2: write the corresponding model in application/model, for example:
 
Configure the model attributes as follows:
Basic addition, deletion, modification, and query operations:
Public function action_test () {/*** @ blog
  
   
* /// Create model interface $ article = ORM: factory ('article', 1); // find the result that meets the condition, if it is find () query only one result $ article-> where ('aid ',' = ', 1)-> find_all (); // Obtain the number of query results echo $ article-> count_all (); // insert operation $ article-> cid = 2; $ article-> title = 'php point-to-point example '; $ article-> content = 'php clickthrough
   
    
Test '; $ article-> save (); // update, $ article = ORM: factory ('article', 3 ); // indicates the record whose id is 3 $ article-> title = "this is the modified title"; $ article-> content = "this is the modified content "; $ article-> save (); // delete operation $ article = ORM: factory ('article', 1); $ article-> delete (); // delete the specified ID // $ orm-> delete_all () // delete the entire table record}
   
  

I used the latest kohana 3.3. the manuals and tutorials are relatively complete:
English document: http://kohanaframework.org/3.3/guide/orm
English document: http://kofans.org/3.2/guide/orm

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.