本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadata::getQuotedTableName方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::getQuotedTableName方法的具体用法?PHP ClassMetadata::getQuotedTableName怎么用?PHP ClassMetadata::getQuotedTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Mapping\ClassMetadata
的用法示例。
在下文中一共展示了ClassMetadata::getQuotedTableName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exists
/**
* Checks whether the given managed entity exists in the database.
*
* @param object $entity
* @return boolean TRUE if the entity exists in the database, FALSE otherwise.
*/
public function exists($entity, array $extraConditions = array())
{
$criteria = $this->_class->getIdentifierValues($entity);
if ($extraConditions) {
$criteria = array_merge($criteria, $extraConditions);
}
$sql = 'SELECT 1 FROM ' . $this->_class->getQuotedTableName($this->_platform) . ' ' . $this->_getSQLTableAlias($this->_class->name) . ' WHERE ' . $this->_getSelectConditionSQL($criteria);
return (bool) $this->_conn->fetchColumn($sql, array_values($criteria));
}
示例2: _generateInsertSQL
/**
* Generates the INSERT SQL used by the persister to persist entities.
*
* @return string
* @internal Result is cached by getInsertSQL() per request.
*/
protected function _generateInsertSQL()
{
$insertSql = '';
$columns = $this->_getInsertColumnList();
if (empty($columns)) {
$insertSql = $this->_platform->getEmptyIdentityInsertSQL($this->_class->getQuotedTableName($this->_platform), $this->_class->getQuotedColumnName($this->_class->identifier[0], $this->_platform));
} else {
$columns = array_unique($columns);
$values = array_fill(0, count($columns), '?');
$insertSql = 'INSERT INTO ' . $this->_class->getQuotedTableName($this->_platform) . ' (' . implode(', ', $columns) . ') ' . 'VALUES (' . implode(', ', $values) . ')';
}
return $insertSql;
}
示例3: lock
/**
* Lock all rows of this entity matching the given criteria with the specified pessimistic lock mode
*
* @param array $criteria
* @param int $lockMode
* @return void
*/
public function lock(array $criteria, $lockMode)
{
$conditionSql = $this->_getSelectConditionSQL($criteria);
if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) {
$lockSql = $this->_platform->getReadLockSql();
} else {
if ($lockMode == \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) {
$lockSql = $this->_platform->getWriteLockSql();
}
}
$sql = 'SELECT 1 FROM ' . $this->_class->getQuotedTableName($this->_platform) . ' ' . $this->_getSQLTableAlias($this->_class->name) . ($conditionSql ? ' WHERE ' . $conditionSql : '') . ' ' . $lockSql;
$params = array_values($criteria);
$this->_conn->executeQuery($sql, $params);
}
示例4: getLockTablesSql
/**
* Get the FROM and optionally JOIN conditions to lock the entity managed by this persister.
*
* @return string
*/
protected function getLockTablesSql()
{
return 'FROM ' . $this->_class->getQuotedTableName($this->_platform) . ' ' . $this->_getSQLTableAlias($this->_class->name);
}
示例5: _gatherRelationJoinColumns
/**
* Gather columns and fk constraints that are required for one part of relationship.
*
* @param array $joinColumns
* @param \Doctrine\DBAL\Schema\Table $theJoinTable
* @param ClassMetadata $class
* @param \Doctrine\ORM\Mapping\AssociationMapping $mapping
* @param array $primaryKeyColumns
* @param array $uniqueConstraints
*/
private function _gatherRelationJoinColumns($joinColumns, $theJoinTable, $class, $mapping, &$primaryKeyColumns, &$uniqueConstraints)
{
$localColumns = array();
$foreignColumns = array();
$fkOptions = array();
foreach ($joinColumns as $joinColumn) {
$columnName = $joinColumn['name'];
$referencedFieldName = $class->getFieldName($joinColumn['referencedColumnName']);
if (!$class->hasField($referencedFieldName)) {
throw new \Doctrine\ORM\ORMException("Column name `" . $joinColumn['referencedColumnName'] . "` referenced for relation from " . $mapping['sourceEntity'] . " towards " . $mapping['targetEntity'] . " does not exist.");
}
$primaryKeyColumns[] = $columnName;
$localColumns[] = $columnName;
$foreignColumns[] = $joinColumn['referencedColumnName'];
if (!$theJoinTable->hasColumn($joinColumn['name'])) {
// Only add the column to the table if it does not exist already.
// It might exist already if the foreign key is mapped into a regular
// property as well.
$fieldMapping = $class->getFieldMapping($referencedFieldName);
$columnDef = null;
if (isset($joinColumn['columnDefinition'])) {
$columnDef = $joinColumn['columnDefinition'];
} else {
if (isset($fieldMapping['columnDefinition'])) {
$columnDef = $fieldMapping['columnDefinition'];
}
}
$columnOptions = array('notnull' => false, 'columnDefinition' => $columnDef);
if (isset($joinColumn['nullable'])) {
$columnOptions['notnull'] = !$joinColumn['nullable'];
}
if ($fieldMapping['type'] == "string") {
$columnOptions['length'] = $fieldMapping['length'];
} else {
if ($fieldMapping['type'] == "decimal") {
$columnOptions['scale'] = $fieldMapping['scale'];
$columnOptions['precision'] = $fieldMapping['precision'];
}
}
$theJoinTable->addColumn($columnName, $class->getTypeOfColumn($joinColumn['referencedColumnName']), $columnOptions);
}
if (isset($joinColumn['unique']) && $joinColumn['unique'] == true) {
$uniqueConstraints[] = array('columns' => array($columnName));
}
if (isset($joinColumn['onUpdate'])) {
$fkOptions['onUpdate'] = $joinColumn['onUpdate'];
}
if (isset($joinColumn['onDelete'])) {
$fkOptions['onDelete'] = $joinColumn['onDelete'];
}
}
$theJoinTable->addUnnamedForeignKeyConstraint($class->getQuotedTableName($this->_platform), $localColumns, $foreignColumns, $fkOptions);
}