Example #1
0
 public function model()
 {
     header('Last-Modified:' . date(DATE_RFC822));
     tools::markTime('test');
     Loader::model('User');
     //         $user = new User;
     //         $user->name = 'imp';
     //         $user->age = 1;
     //         $user->save();
     //         $db = DB::connection()->db();
     //         $db->setTable('user');
     //         $db->beginTransaction();
     //         $db->insert('user', array('username' => 'air_' . mt_rand(1000000, 9999999), 'password' => 123456));
     //         $db->insert('user', array('username' => 'air5', 'password' => 123456));
     //         //$db->commit();
     //         $db->rollback();
     //         die();
     //         DB::begin();
     //         $res = DB::table('user')->insert(array('username' => 'air_' . mt_rand(1000000, 9999999), 'password' => 123456));
     //         $res2 = DB::table('user')->insert(array('id' => 6, 'username' => 'air5', 'password' => 123456));
     //         //DB::commit();
     //         //DB::rollback();
     //         die();
     DB::transaction(function () {
         $res = DB::table('user')->insert(array('username' => 'air_' . mt_rand(1000000, 9999999), 'password' => 123456));
         $res2 = DB::table('user')->insert(array('username' => 'air5', 'password' => 123456));
     });
     die;
     tools::markTime('init2');
     $res = DB::table('test')->join('user')->on('user', 'test.id', '=', 'user.id')->leftJoin('test2')->on('test2', 'test2.id', '=', 'test.id')->all();
     hprint($res, 1);
     //hprint($_SERVER, 1);
     $res = User::find(5);
     hprint($res);
     tools::markTime('init2.2');
     $res = User::where(array('id' => 6))->get();
     hprint($res);
     $user = new User();
     tools::markTime('init4');
     $res = $user->getOne();
     hprint($res);
     //$res = user::all();
     //$res = User::where(array('id' => 3))->all();
     //$res = User::create(array('username' => 'imp_' . mt_rand(1000, 9999), 'password' => 123456, 'time' => time()), true);
     //hprint($res);
     $user->all1();
     //$res = DB::table('test')->where(array('id' => 1))->get();
     //         DB::connection('imp');
     //         $res2 = DB::table('system_user')->where(array('id' => 1))->get();
     //         hprint($res2);
     tools::markTime('init3');
     echo tools::showTime();
 }