Doctrine\DBAL\Connection::quoteIdentifier PHP Method

quoteIdentifier() public method

Delimiting style depends on the underlying database platform that is being used. NOTE: Just because you CAN use quoted identifiers does not mean you SHOULD use them. In general, they end up causing way more problems than they solve.
public quoteIdentifier ( string $str ) : string
$str string The name to be quoted.
return string The quoted name.
    public function quoteIdentifier($str)
    {
        return $this->getDatabasePlatform()->quoteIdentifier($str);
    }

Usage Example

コード例 #1
0
 /**
  * @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;
 }
All Usage Examples Of Doctrine\DBAL\Connection::quoteIdentifier