コード例 #1
0
ファイル: orm.php プロジェクト: nephie/Moya
 public static function query($query)
 {
     $shortq = preg_replace('/\\s*/m', '', $query);
     if (!self::$cachedStatements[$shortq] instanceof statement) {
         $lexer = new lexer();
         $parsedQuery = $lexer->parse($query);
         $statement = new statement();
         $statement->setQuery($parsedQuery);
         $datastore = $parsedQuery->getModel()->getDatastore();
         $driverclass = '\\Moya\\core\\orm\\drivers\\' . config::get('datastore', $datastore . '/driver');
         $driver = $driverclass::getInstance($datastore);
         $statement->setDriver($driver);
         $statement->setCompiledquery($driver->compileQuery($parsedQuery));
         echo $statement->getCompiledquery() . "\n";
         self::$cachedStatements[$shortq] = $statement->prepare();
     }
     return self::$cachedStatements[$shortq];
 }
コード例 #2
0
ファイル: where.php プロジェクト: nephie/Moya
 protected function parseField(lexer $lexer)
 {
     $lexer->moveNext();
     $object = '';
     if ($lexer->isNextToken('.')) {
         $modelclass = inflector::getModelfromcontext($lexer->getCurrentToken());
         $model = new $modelclass();
         $lexer->moveNext();
         $lexer->moveNext();
     } else {
         $model = $lexer->query->getModel();
     }
     $field = $lexer->getCurrentToken();
     if (!$lexer->isNextToken(']')) {
         throw new \Exception('Invalid query syntax: Expected \']\' after ' . $lexer->getCurrentToken());
     }
     $lexer->moveNext();
     $lexer->moveNext();
     return array('model' => $model, 'field' => $field);
 }