/** * Select Bind测试 */ private function testBindSelect() { //as name测试 $select = \HuiLib\Db\Query::select()->columns(array('PrimaryID' => 'id', 'Description' => 'test'))->table(array('t' => 'test.test'))->join(array('n' => 'name'), 't.id=n.tid', 'n.name as sname, n.sid as bbid')->where(Where::createPlain('t.id=:id'))->limit(10)->offset(0); $re = $select->prepare()->execute(array('id' => 14)); \HuiLib\Helper\Debug::out($re->fetchAll()); echo $select->toString(); }
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'); }