/** {@inheritdoc} */
 protected function _getInsertColumnList()
 {
     $columns = parent::_getInsertColumnList();
     // Add discriminator column to the INSERT SQL
     $columns[] = $this->_class->discriminatorColumn['name'];
     return $columns;
 }
 /** {@inheritdoc} */
 protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias)
 {
     // Ensure that the filters are applied to the root entity of the inheritance tree
     $targetEntity = $this->_em->getClassMetadata($targetEntity->rootEntityName);
     // we dont care about the $targetTableAlias, in a STI there is only one table.
     return parent::generateFilterConditionSQL($targetEntity, $targetTableAlias);
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 protected function getLockTablesSql($lockMode)
 {
     $joinSql = '';
     $identifierColumns = $this->class->getIdentifierColumnNames();
     $baseTableAlias = $this->getSQLTableAlias($this->class->name);
     // INNER JOIN parent tables
     foreach ($this->class->parentClasses as $parentClassName) {
         $conditions = array();
         $tableAlias = $this->getSQLTableAlias($parentClassName);
         $parentClass = $this->em->getClassMetadata($parentClassName);
         $joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON ';
         foreach ($identifierColumns as $idColumn) {
             $conditions[] = $baseTableAlias . '.' . $idColumn . ' = ' . $tableAlias . '.' . $idColumn;
         }
         $joinSql .= implode(' AND ', $conditions);
     }
     return parent::getLockTablesSql($lockMode) . $joinSql;
 }
 /** {@inheritdoc} */
 protected function _getSelectConditionSQL(array $criteria, $assoc = null)
 {
     $conditionSql = parent::_getSelectConditionSQL($criteria, $assoc);
     // Append discriminator condition
     if ($conditionSql) {
         $conditionSql .= ' AND ';
     }
     $values = array();
     if ($this->_class->discriminatorValue !== null) {
         // discriminators can be 0
         $values[] = $this->_conn->quote($this->_class->discriminatorValue);
     }
     $discrValues = array_flip($this->_class->discriminatorMap);
     foreach ($this->_class->subClasses as $subclassName) {
         $values[] = $this->_conn->quote($discrValues[$subclassName]);
     }
     $conditionSql .= $this->_getSQLTableAlias($this->_class->name) . '.' . $this->_class->discriminatorColumn['name'] . ' IN (' . implode(', ', $values) . ')';
     return $conditionSql;
 }