/**
  * 首页方法
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     for ($i = 0; $i < 100; $i++) {
         __print(StringUtils::genGlobalUid());
     }
     die;
 }
 /**
  * @see IModel::insert()
  */
 public function insert($data)
 {
     $data = $this->loadFilterData($data);
     if ($data == false) {
         return false;
     }
     if (!isset($data['id'])) {
         $data['id'] = StringUtils::genGlobalUid();
     }
     $id = $this->db->insert($this->table, $data);
     if ($id === true) {
         $id = $data['id'];
     }
     return $id;
 }
 public function mysql()
 {
     $model = Loader::model("user");
     //添加数据 C_Model::insert();
     $address = array('东莞', '深圳', '广州', '北京', '上海', '杭州');
     for ($i = 0; $i < 100; $i++) {
         $data = array("id" => StringUtils::genGlobalUid(true), "name" => "user_{$i}", "age" => $i, "address" => $address[mt_rand(0, 5)]);
         var_dump($model->insert($data));
     }
     //C_Model::query();
     //        $list = $model->query("select * from fiidee_user order by id desc limit 20");
     //        __print($list);
     //C_Model:replace();
     //        $data = array(
     //            'id' => 'B21A-57B30877-0027B08C-748A-84D4EB10',
     //            'name' => 'xiaoyang',
     //            'address' => '南城高盛');
     //        var_dump($model->replace($data));
     //C_Model::getItem()
     //        $condition = array('id' => 'B21A-57B30877-0027B08C-748A-84D4EB10');
     //        $one = $model->getItem($condition);
     //        __print($one);
     //C_Model::delete()
     //        $id = 'B21A-57B30877-0027B08C-748A-84D4EB10';
     //        $model->delete($id);
     //C_Model::deletes(), C_Model::find
     //        $conditions = array(
     //            'age' => array('>' => 20, '<' => 30),
     //            '$or' => array('name' => 'xiaoming', 'age' => '>30'),
     //            'address' => '深圳'
     //        );
     //
     //        $gets = array('id', 'name', 'address');
     //        $sort = array('id' => -1, 'name' => 1);
     //        $list = $model->where($conditions)
     //            ->field($gets)
     //            ->sort($sort)
     //            ->limit(0, 20)
     //            ->group('address')
     //            ->having(array('address' => array('$in' => array('深圳', '广州', '北京'))))
     //            ->find();
     //C_Model::update
     $data = array('name' => 'xiaoming', 'age' => 30, 'address' => '我爱北京天安门');
     $conditions = array('id' => 'B21A-57B30872-01655B98-538F-FBED5277');
     $model->updates($data, $conditions);
     //        __print($model->where($conditions)->findOne());
     //C_Model::count
     //        $conditions = array('id' => '>B21A-57B30872-01655B98-538F-FBED5277');
     //        var_dump($model->count($conditions));
     //C_Model::increase
     //        $condition = array('id' => array('$in' => array('B21A-57B30872-01655B98-538F-FBED5277', 'B21A-57B30872-0125BDA8-8184-2B481B89')));
     //        //$model->batchIncrease('age', 10, $condition);
     //        $model->batchReduce('age', 10, $condition);
     //        __print($model->getItems($condition));
     //C_Model::set
     //        $condition = array('id' => array('$in' => array('B21A-57B30872-01655B98-538F-FBED5277', 'B21A-57B30872-0125BDA8-8184-2B481B89')));
     //        $model->sets('age', 200, $condition);
     //        __print($model->getItems($condition));
     $model->beginTransaction();
     $condition = array('id' => array('$in' => array('B21A-57B30872-01655B98-538F-FBED5277', 'B21A-57B30872-0125BDA8-8184-2B481B89')));
     $model->sets('age', 500, $condition);
     __print($model->getItems($condition));
     $model->rollback();
     __print($model->getItems($condition));
     die('f**k it whatever.');
 }