Source for file Pgsql.php
Documentation is available at Pgsql.php
* $Id: Pgsql.php 2033 2007-07-21 15:17:17Z romanb $
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
* @subpackage Doctrine_DataDict
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Paul Cooper <pgc@ucecom.com>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @version $Revision: 2033 $
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @param array $reservedKeyWords an array of reserved keywords by pgsql
protected static $reservedKeyWords =
array(
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
* @param array $field associative array with the name of the properties
* of the field being declared as array indexes. Currently, the types
* of supported field properties are as follows:
* Integer value that determines the maximum length of the text
* field. If this argument is missing the field should be
* declared to have the longest length allowed by the DBMS.
* Text value to be used as default for this field.
* Boolean flag that indicates whether this field is constrained
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
if ( ! isset
($field['type'])) {
switch ($field['type']) {
$length =
(isset
($field['length']) &&
$field['length']) ?
$field['length'] :
null;
// TODO: $this->conn->options['default_text_field_length'];
$fixed =
((isset
($field['fixed']) &&
$field['fixed']) ||
$field['type'] ==
'char') ?
true :
false;
return $fixed ?
($length ?
'CHAR('.
$length.
')' :
'CHAR('.
$this->conn->options['default_text_field_length'].
')')
:
($length ?
'VARCHAR('.
$length.
')' :
'TEXT');
if (!empty($field['autoincrement'])) {
if (!empty($field['length'])) {
$length =
$field['length'];
if (!empty($field['length'])) {
$length =
$field['length'];
} elseif ($length ==
3 ||
$length ==
4) {
return 'TIME without time zone';
return 'TIMESTAMP without time zone';
$length =
!empty($field['length']) ?
$field['length'] :
18;
$scale =
!empty($field['scale']) ?
$field['scale'] :
$this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
return 'NUMERIC('.
$length.
','.
$scale.
')';
* Maps a native array description of a field to a portable Doctrine datatype and length
* @param array $field native field description
* @return array containing the various possible types, length, sign, fixed
$length =
(isset
($field['length'])) ?
$field['length'] :
null;
if ($length ==
'-1' && isset
($field['atttypmod'])) {
$length =
$field['atttypmod'] -
4;
$unsigned =
$fixed =
null;
if ( ! isset
($field['name'])) {
} elseif (strstr($dbType, 'text')) {
return array('type' =>
$type,
* Obtain DBMS specific SQL code portion needed to declare an integer type
* field to be used in statements like CREATE TABLE.
* @param string $name name the field to be declared.
* @param array $field associative array with the name of the properties
* of the field being declared as array indexes. Currently, the types
* of supported field properties are as follows:
* Boolean flag that indicates whether the field should be
* declared as unsigned integer if possible.
* Integer value to be used as default for this field.
* Boolean flag that indicates whether this field is constrained
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
if (!empty($field['unsigned'])) {
$this->conn->warnings[] = "unsigned integer field \"$name\" is being declared as signed integer";
if ( ! empty($field['autoincrement'])) {
$name =
$this->conn->quoteIdentifier($name, true);
if ($field['default'] ===
'') {
$field['default'] =
empty($field['notnull']) ?
null :
0;
$default =
' DEFAULT '.
$this->conn->quote($field['default'], $field['type']);
elseif (empty($field['notnull'])) {
$default = ' DEFAULT NULL';
$notnull =
empty($field['notnull']) ?
'' :
' NOT NULL';
$name =
$this->conn->quoteIdentifier($name, true);
* parses a literal boolean value and returns
* @param string $value boolean value to be parsed
* @return string parsed boolean value