create() публичный статический Метод

public static create ( ) : Dialect
Результат Dialect
Пример #1
0
 /**
  * @throws GeneratorException
  * @return Dialect
  */
 public function dialectAdapter()
 {
     $dialect = DialectFactory::create();
     $dialectShortName = $this->objectShortClassName($dialect);
     $selfClassPath = $this->thisNamespace();
     $generatorDialect = "{$selfClassPath}\\Dialect\\{$dialectShortName}";
     if (!class_exists($generatorDialect)) {
         throw new GeneratorException("Model generator for '{$dialectShortName}' does not exists.");
     }
     return new $generatorDialect($this->tableName);
 }
Пример #2
0
 public function execute()
 {
     if (empty($this->_models)) {
         return;
     }
     $this->_callBeforeSaveCallbacks();
     $metaInstance = Arrays::first($this->_models);
     $columns = $metaInstance->getFieldsWithoutPrimaryKey();
     $primaryKey = $metaInstance->getIdName();
     $table = $metaInstance->getTableName();
     $sql = DialectFactory::create()->batchInsert($table, $primaryKey, $columns, count($this->_models));
     $params = $this->_prepareParams($primaryKey);
     $ids = Arrays::flatten(Db::getInstance()->query($sql, $params)->fetchAll(PDO::FETCH_NUM));
     $this->_assignPrimaryKeys($primaryKey, $ids);
     $this->_callAfterSaveCallbacks();
 }
Пример #3
0
 public function tableOrSubQuery()
 {
     if ($this->_query->table instanceof Query) {
         return '(' . DialectFactory::create()->buildQuery($this->_query->table) . ')';
     }
     return $this->_query->table;
 }
Пример #4
0
 public static function getException($errorInfo, $querySql)
 {
     $exceptionClassName = DialectFactory::create()->getExceptionForError($errorInfo);
     return new $exceptionClassName(sprintf("Exception: query: %s failed: %s (%s)", $querySql, self::errorMessageFromErrorInfo($errorInfo), self::_errorCodesFromErrorInfo($errorInfo)));
 }
Пример #5
0
 public function __construct($db, $query)
 {
     $this->_db = $db;
     $this->_query = $query;
     $this->_adapter = DialectFactory::create();
 }
Пример #6
0
 public function toSql($fieldName)
 {
     $dialect = DialectFactory::create();
     $regexpMatcher = $dialect->regexpMatcher();
     return $fieldName . ' ' . $regexpMatcher . ' ?';
 }
Пример #7
0
 public function toSql()
 {
     $sql = DialectFactory::create()->buildQuery($this->query);
     return $this->negate ? "NOT EXISTS ({$sql})" : "EXISTS ({$sql})";
 }