1. SQL bound variable:
$title = ' iat001 '; // Binding Variables $result $title) ->execute ();
// Direct Assignment $result = Db::query ("SELECT * from articles WHERE title =: Title")->param (' title ', ' iat001 ')->execute ();
// Binding Multiple Parameters $result = Db::query ("SELECT * from articles WHERE title =: Title and BODY =: Body")->parameters (array $title, ' body ' = ' body001 '))->execute ();
2. Data cache
// cached () Three parameters: Cache time, cache file, whether to store null value $result false) ->execute ();
// Delete articles cache files Cache::d elete ("articles"); // Delete all caches in the DB directory Cache::d elete_all ("db");
3. Business
Try { //Transaction StartDb::start_transaction (); $result= Db::insert (' articles ')->set (Array(' title ' = ' iat001 ', ' body ' = ' body001 ')) -execute (); //Custom return informationDb::escape (' ERROR: '.$msg); //End of transactionDb::commit_transaction ();} Catch(Exception $e) { //Transaction RollbackDb::rollback_transaction (); //Rollback Prompt Information $e-getMessage ();}
Fuelphp series------Miscellaneous