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