예제 #1
0
 /**
  * Select 普通测试
  */
 private function testAdapterSelect()
 {
     $select = \HuiLib\Db\Query::select()->table('test.test')->where(Where::createPair('id', 2))->limit(10)->offset(0)->enableForUpdate();
     $re = $select->query();
     \HuiLib\Helper\Debug::out($re->fetchAll());
     echo $select->toString();
 }
예제 #2
0
 /**
  * 测试通过静态函数获取
  */
 private function testStaticInit()
 {
     $cache = \HuiLib\Cache\CacheBase::getDefault(Front::getInstance()->getAppConfig());
     echo $cache->toString();
     $cache->add('hanhui2', date('Y-m-d H:i:s'));
     echo $cache->get('hanhui2');
     //测试数组
     $cache->replace('array', Front::getInstance()->getAppConfig()->getByKey('cache.memcache'));
     \HuiLib\Helper\Debug::out($cache->get('array'));
     $cache->add('count', 0);
     $cache->increase('count');
     echo $cache->get('count');
     $cache = \HuiLib\Cache\CacheBase::getRedis(Front::getInstance()->getAppConfig());
     echo $cache->toString();
     $cache = \HuiLib\Cache\CacheBase::getMemcache(Front::getInstance()->getAppConfig());
     echo $cache->toString();
     $cache = \HuiLib\Cache\CacheBase::getApc(Front::getInstance()->getAppConfig());
     echo $cache->toString();
     $cache = \HuiLib\Cache\CacheBase::getFile(Front::getInstance()->getAppConfig());
     echo $cache->toString();
 }
예제 #3
0
 private function testWhereBenchMark()
 {
     Debug::mark('startSelect');
     $select = Query::select('test');
     Debug::mark('endSelect');
     Debug::mark('startWhere');
     $where1 = Where::createPair('test', 'zzzzzzzzzzzzzzzzzzzzzzz')->orCase(Where::createPlain('test is null'));
     $where = Where::createQuote('num in (?)', array(3, 5, 16))->andCase($where1, Where::HAND_LEFT);
     Debug::mark('endWhere');
     //初始化adapter后才能escape
     $select->where($where);
     //echo $select->toString();
     Debug::mark('startQuery');
     $re = $select->query();
     Debug::mark('endQuery');
     \HuiLib\Helper\Debug::out($re->fetchAll());
     Debug::elapsed('startSelect', 'endSelect');
     Debug::elapsed('startWhere', 'endWhere');
     Debug::elapsed('startQuery', 'endQuery');
     Debug::elapsed('startSelect', 'endQuery');
     Debug::elapsed('startSelect', 'endALL');
 }