/** * Gets the INSERT SQL used by the persister to persist a new entity. * * @return string */ protected function _getInsertSQL() { if ($this->_insertSql === null) { $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) . ')'; } $this->_insertSql = $insertSql; } return $this->_insertSql; }
/** * Gets the INSERT SQL used by the persister to persist a new entity. * * @return string */ protected function _getInsertSQL() { if ($this->_insertSql === null) { $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(); foreach ($columns as $column) { $placeholder = '?'; if (isset($this->_columnTypes[$column]) && isset($this->_class->fieldMappings[$this->_class->fieldNames[$column]]['requireSQLConversion'])) { $type = Type::getType($this->_columnTypes[$column]); $placeholder = $type->convertToDatabaseValueSQL('?', $this->_platform); } $values[] = $placeholder; } $insertSql = 'INSERT INTO ' . $this->_class->getQuotedTableName($this->_platform) . ' (' . implode(', ', $columns) . ') VALUES (' . implode(', ', $values) . ')'; } $this->_insertSql = $insertSql; } return $this->_insertSql; }