當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Connection::quoteIdentifier方法代碼示例

本文整理匯總了PHP中Doctrine\DBAL\Connection::quoteIdentifier方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::quoteIdentifier方法的具體用法?PHP Connection::quoteIdentifier怎麽用?PHP Connection::quoteIdentifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\DBAL\Connection的用法示例。


在下文中一共展示了Connection::quoteIdentifier方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getQueryBuilderForEntity

 /**
  * @param $data
  * @param $entity
  * @param $primaryId
  * @return QueryBuilder
  */
 public function getQueryBuilderForEntity($data, $entity, $primaryId)
 {
     $metaData = $this->modelManager->getClassMetadata($entity);
     $table = $metaData->table['name'];
     $builder = $this->getQueryBuilder();
     if ($primaryId) {
         $id = $builder->createNamedParameter($primaryId, \PDO::PARAM_INT);
         $builder->update($table);
         //update article id in case we don't have any field for update
         $builder->set('id', $id);
         $builder->where('id = ' . $id);
     } else {
         $builder->insert($table);
     }
     foreach ($data as $field => $value) {
         if (!array_key_exists($field, $metaData->fieldMappings)) {
             continue;
         }
         $key = $this->connection->quoteIdentifier($metaData->fieldMappings[$field]['columnName']);
         $value = $this->getNamedParameter($value, $field, $metaData, $builder);
         if ($primaryId) {
             $builder->set($key, $value);
         } else {
             $builder->setValue($key, $value);
         }
     }
     return $builder;
 }
開發者ID:shopwareLabs,項目名稱:SwagImportExport,代碼行數:34,代碼來源:DbalHelper.php

示例2: getQuotedFields

 /**
  * @return array
  */
 private function getQuotedFields()
 {
     $fields = [];
     foreach (self::$columnNames as $field) {
         $fields[] = $this->connection->quoteIdentifier($field);
     }
     return $fields;
 }
開發者ID:luisbrito,項目名稱:Phraseanet,代碼行數:11,代碼來源:DbalDataboxFieldRepository.php

示例3: __construct

 public function __construct(Connection $conn, StorageKeyGeneratorInterface $storageKeyGenerator)
 {
     $this->conn = $conn;
     $this->storageKeyGenerator = $storageKeyGenerator;
     $this->schemaManager = $this->conn->getSchemaManager();
     $this->keyColumn = $this->conn->quoteIdentifier(self::KEY_COLUMN);
     $this->valueColumn = $this->conn->quoteIdentifier(self::VALUE_COLUMN);
 }
開發者ID:alinnflorinn,項目名稱:CraueFormFlowBundle,代碼行數:8,代碼來源:DoctrineStorage.php

示例4: fetchAll

 /**
  * Fetch all 
  *
  * @return array
  */
 public function fetchAll()
 {
     $tableName = $this->connection->quoteIdentifier($this->tableName);
     $sql = "SELECT version FROM {$tableName} ORDER BY version ASC";
     $all = $this->connection->fetchAll($sql);
     return array_map(function ($v) {
         return $v['version'];
     }, $all);
 }
開發者ID:edisonnica,項目名稱:phpmig,代碼行數:14,代碼來源:DBAL.php

示例5: quoteIdentifiers

 /**
  * @param  array $rows
  * @return array
  */
 protected function quoteIdentifiers(array $rows)
 {
     $quotedRows = array_map(function ($row) {
         $quoted = [];
         foreach ($row as $identifier => $value) {
             $quoted[$this->connection->quoteIdentifier($identifier)] = $value;
         }
         return $quoted;
     }, $rows);
     return $quotedRows;
 }
開發者ID:comphppuebla,項目名稱:dbal-fixtures,代碼行數:15,代碼來源:ConnectionPersister.php

示例6: findBy

 /**
  * Find User instances that match the given criteria.
  *
  * @param array $criteria
  * @param array $options An array of the following options (all optional):<pre>
  *      limit (int|array) The maximum number of results to return, or an array of (offset, limit).
  *      order_by (string|array) The name of the column to order by, or an array of column name and direction, ex. array(time_created, DESC)
  * </pre>
  * @return User[] An array of matching User instances, or an empty array if no matching users were found.
  */
 public function findBy(array $criteria = array(), array $options = array())
 {
     // Check the identity map first.
     if (array_key_exists('id', $criteria) && array_key_exists($criteria['id'], $this->identityMap)) {
         return array($this->identityMap[$criteria['id']]);
     }
     list($common_sql, $params) = $this->createCommonFindSql($criteria);
     $sql = 'SELECT * ' . $common_sql;
     if (array_key_exists('order_by', $options)) {
         list($order_by, $order_dir) = is_array($options['order_by']) ? $options['order_by'] : array($options['order_by']);
         $sql .= 'ORDER BY ' . $this->conn->quoteIdentifier($order_by) . ' ' . ($order_dir == 'DESC' ? 'DESC' : 'ASC') . ' ';
     }
     if (array_key_exists('limit', $options)) {
         list($offset, $limit) = is_array($options['limit']) ? $options['limit'] : array(0, $options['limit']);
         $sql .= 'LIMIT ' . (int) $offset . ', ' . (int) $limit . ' ';
     }
     $data = $this->conn->fetchAll($sql, $params);
     $users = array();
     foreach ($data as $userData) {
         if (array_key_exists($userData['id'], $this->identityMap)) {
             $user = $this->identityMap[$userData['id']];
         } else {
             $user = $this->hydrateUser($userData);
             $this->identityMap[$user->getId()] = $user;
         }
         $users[] = $user;
     }
     return $users;
 }
開發者ID:oppai,項目名稱:silex-simpleuser,代碼行數:39,代碼來源:UserManager.php

示例7: updateJob

 /**
  * {@inheritdoc}
  */
 public function updateJob(Enlight_Components_Cron_Job $job)
 {
     $data = [];
     $data['action'] = $job->getAction();
     $data[$this->connection->quoteIdentifier('interval')] = $job->getInterval();
     $data['data'] = serialize($job->getData());
     $data['active'] = $job->getActive() ? '1' : '0';
     $data['next'] = $job->getNext() ? $job->getNext()->toString('YYYY-MM-dd HH:mm:ss') : null;
     $data['start'] = $job->getStart() ? $job->getStart()->toString('YYYY-MM-dd HH:mm:ss') : null;
     $data['end'] = $job->getEnd() ? $job->getEnd()->toString('YYYY-MM-dd HH:mm:ss') : null;
     if (is_null($job->getId())) {
         $this->connection->insert($this->tableName, $data);
     } else {
         $this->connection->update($this->tableName, $data, ['id' => $job->getId()]);
     }
 }
開發者ID:GerDner,項目名稱:luck-docker,代碼行數:19,代碼來源:DBAL.php

示例8: convertToCharacterSetAndCollation

 /**
  * Convert the tables in the current database to use given character set and collation.
  *
  * @param string $characterSet Character set to convert to
  * @param string $collation Collation to set, must be compatible with the character set
  * @param string $outputPathAndFilename
  * @param boolean $verbose
  * @throws ConnectionException
  * @throws DBALException
  */
 protected function convertToCharacterSetAndCollation($characterSet = 'utf8', $collation = 'utf8_unicode_ci', $outputPathAndFilename = null, $verbose = false)
 {
     $statements = ['SET foreign_key_checks = 0'];
     $statements[] = 'ALTER DATABASE ' . $this->connection->quoteIdentifier($this->persistenceSettings['backendOptions']['dbname']) . ' CHARACTER SET ' . $characterSet . ' COLLATE ' . $collation;
     $tableNames = $this->connection->getSchemaManager()->listTableNames();
     foreach ($tableNames as $tableName) {
         $statements[] = 'ALTER TABLE ' . $this->connection->quoteIdentifier($tableName) . ' DEFAULT CHARACTER SET ' . $characterSet . ' COLLATE ' . $collation;
         $statements[] = 'ALTER TABLE ' . $this->connection->quoteIdentifier($tableName) . ' CONVERT TO CHARACTER SET ' . $characterSet . ' COLLATE ' . $collation;
     }
     $statements[] = 'SET foreign_key_checks = 1';
     if ($outputPathAndFilename === null) {
         try {
             $this->connection->beginTransaction();
             foreach ($statements as $statement) {
                 if ($verbose) {
                     $this->outputLine($statement);
                 }
                 $this->connection->exec($statement);
             }
             $this->connection->commit();
         } catch (\Exception $exception) {
             $this->connection->rollBack();
             $this->outputLine($exception->getMessage());
             $this->outputLine('[ERROR] The transaction was rolled back.');
         }
     } else {
         file_put_contents($outputPathAndFilename, implode(';' . PHP_EOL, $statements) . ';');
     }
 }
開發者ID:neos,項目名稱:flow-development-collection,代碼行數:39,代碼來源:DatabaseCommandController.php

示例9: lockTables

 /**
  * Lock one or more tables
  *
  * @param array $arrTables An array of table names to be locked
  */
 public function lockTables($arrTables)
 {
     $arrLocks = array();
     foreach ($arrTables as $table => $mode) {
         $arrLocks[] = $this->resConnection->quoteIdentifier($table) . ' ' . $mode;
     }
     $this->resConnection->exec('LOCK TABLES ' . implode(', ', $arrLocks) . ';');
 }
開發者ID:contao,項目名稱:core-bundle,代碼行數:13,代碼來源:Database.php

示例10: quoteIdentifiers

 /**
  * @param array $where column => value pairs
  * @return array `column` => value pairs
  */
 protected function quoteIdentifiers(array $where)
 {
     $columns = array_map(function ($column) {
         return $this->db->quoteIdentifier($column);
     }, array_keys($where));
     $identifier = array_combine($columns, array_values($where));
     return $identifier;
 }
開發者ID:thewunder,項目名稱:corma,代碼行數:12,代碼來源:QueryHelper.php

示例11: delete

 /**
  * Delete a User from the database.
  *
  * @param User $user
  */
 public function delete(User $user)
 {
     $this->dispatcher->dispatch(UserEvents::BEFORE_DELETE, new UserEvent($user));
     $this->clearIdentityMap($user);
     $this->conn->executeUpdate('DELETE FROM ' . $this->conn->quoteIdentifier($this->userTableName) . ' WHERE ' . $this->getUserColumns('id') . ' = ?', array($user->getId()));
     $this->conn->executeUpdate('DELETE FROM ' . $this->conn->quoteIdentifier($this->userCustomFieldsTableName) . ' WHERE ' . $this->getUserColumns('user_id') . ' = ?', array($user->getId()));
     $this->dispatcher->dispatch(UserEvents::AFTER_DELETE, new UserEvent($user));
 }
開發者ID:dactivo,項目名稱:silex-simpleuser,代碼行數:13,代碼來源:UserManager.php

示例12: quoteColumns

 /**
  * Quote the column names.
  * @param array $data
  * @return array
  */
 private function quoteColumns(array $data)
 {
     $safeData = [];
     foreach ($data as $key => $value) {
         $key = $this->connection->quoteIdentifier($key);
         $safeData[$key] = $value;
     }
     return $safeData;
 }
開發者ID:mnapoli,項目名稱:blackbox,代碼行數:14,代碼來源:DatabaseTable.php

示例13: quoteIdentifier

 /**
  * Tries to autodetect, if identifier has to be quoted and quotes it.
  *
  * @param string $expression
  * @return string
  */
 public function quoteIdentifier($expression)
 {
     $expression = trim($expression);
     if ($expression[0] === $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
         return $expression;
         // already quoted
     }
     return parent::quoteIdentifier($expression);
 }
開發者ID:LidskaSila,項目名稱:Doctrine,代碼行數:15,代碼來源:Connection.php

示例14: write

 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     if ($this->columnMap === null) {
         $dataToInsert = $record;
     } else {
         $dataToInsert = array();
         foreach ($this->columnMap as $columnName => $fieldKey) {
             if (isset($record[$fieldKey])) {
                 $dataToInsert[$this->conn->quoteIdentifier($columnName)] = $record[$fieldKey];
             }
         }
     }
     array_walk_recursive($dataToInsert, function (&$value) {
         // Convert DateTime instances to ISO-8601 Strings
         if ($value instanceof \DateTime) {
             $value = $value->format(\DateTime::ISO8601);
         }
     });
     $this->conn->insert($this->table, $dataToInsert);
 }
開發者ID:GerDner,項目名稱:luck-docker,代碼行數:23,代碼來源:DoctrineDBALHandler.php

示例15: quoteIdentifier

 /**
  * {@inheritdoc}
  */
 public function quoteIdentifier($identifier)
 {
     if (ConnectionDecoratorChain::isDecorate()) {
         return (new ConnectionDecoratorChain($this, $this->decorators))->quoteIdentifier($identifier);
     }
     try {
         return $this->conn->quoteIdentifier($identifier);
     } catch (\Exception $e) {
         throw $this->convertException($e);
     }
 }
開發者ID:koolkode,項目名稱:database,代碼行數:14,代碼來源:Connection.php


注:本文中的Doctrine\DBAL\Connection::quoteIdentifier方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。