Framework workflow:
Load framework file》Load parameter setting object》Perform initialization settings》Load project setting parameters》Get controller and controller method》Execute controller event
Usage example is:
Copy the code as follows:
class DefaultController extends AppController
{
protected $components = array('smarty');
/**Default event (method)*/
public function index()
{
$db_test = M('members') ; //Load and instantiate a model
/**adding data*/
$data = array(
'title' => 'Write test',
'body' => 'Written content' ,
);
$result = $db_test->create($data);
if(FALSE != $result)
{
dump("
exampel 1:
Data written successfully!
exampel 2:
");
$data = array(
array('title'=>'Data 1', 'body'=>'Content 1'),
array('title'=> 'Data 2', 'body'=>'Content 2'),
array('title'=>'Data 3', 'body'=>'Content 3'),
array('title'= >'data4', 'body'=>'content4'),
array('title'=>'data5', 'body'=>'content5'),
);
foreach ($data as $item)
{
$result = $db_test->create($item);
if(FALSE != $result)
{
dump("data".$item[' title']."Write successfully!
");
}
}
dump("
exampel 3:
Data updated successfully !
exampel 3:
Data deleted successfully!
Thank you for reading, please pay attention to PHP for more related articles Chinese website (m.sbmmt.com)!