当前位置: 首页>>代码示例>>PHP>>正文


PHP pg_field_type_oid函数代码示例

本文整理汇总了PHP中pg_field_type_oid函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_field_type_oid函数的具体用法?PHP pg_field_type_oid怎么用?PHP pg_field_type_oid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pg_field_type_oid函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: castResult

 public static function castResult($result, array $a, Stub $stub, $isNested)
 {
     $a['num rows'] = pg_num_rows($result);
     $a['status'] = pg_result_status($result);
     if (isset(self::$resultStatus[$a['status']])) {
         $a['status'] = new ConstStub(self::$resultStatus[$a['status']], $a['status']);
     }
     $a['command-completion tag'] = pg_result_status($result, PGSQL_STATUS_STRING);
     if (-1 === $a['num rows']) {
         foreach (self::$diagCodes as $k => $v) {
             $a['error'][$k] = pg_result_error_field($result, $v);
         }
     }
     $a['affected rows'] = pg_affected_rows($result);
     $a['last OID'] = pg_last_oid($result);
     $fields = pg_num_fields($result);
     for ($i = 0; $i < $fields; ++$i) {
         $field = array('name' => pg_field_name($result, $i), 'table' => sprintf('%s (OID: %s)', pg_field_table($result, $i), pg_field_table($result, $i, true)), 'type' => sprintf('%s (OID: %s)', pg_field_type($result, $i), pg_field_type_oid($result, $i)), 'nullable' => (bool) pg_field_is_null($result, $i), 'storage' => pg_field_size($result, $i) . ' bytes', 'display' => pg_field_prtlen($result, $i) . ' chars');
         if (' (OID: )' === $field['table']) {
             $field['table'] = null;
         }
         if ('-1 bytes' === $field['storage']) {
             $field['storage'] = 'variable size';
         } elseif ('1 bytes' === $field['storage']) {
             $field['storage'] = '1 byte';
         }
         if ('1 chars' === $field['display']) {
             $field['display'] = '1 char';
         }
         $a['fields'][] = new EnumStub($field);
     }
     return $a;
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:33,代码来源:PgSqlCaster.php

示例2: __construct

 /**
  * Constructor.
  *
  * @param resource    $resource SQL result resource.
  * @param TypeConverterFactory $factory
  * @param array       $types    Types information, used to convert output values (overrides auto-generated types).
  * @throws exceptions\InvalidArgumentException
  */
 public function __construct($resource, TypeConverterFactory $factory, array $types = array())
 {
     if (!is_resource($resource) || 'pgsql result' !== get_resource_type($resource)) {
         throw new exceptions\InvalidArgumentException(sprintf("%s requires a query result resource, '%s' given", __CLASS__, is_resource($resource) ? 'resource(' . get_resource_type($resource) . ')' : gettype($resource)));
     }
     $this->_resource = $resource;
     $this->_converterFactory = $factory;
     $this->_numRows = pg_num_rows($this->_resource);
     $this->_numFields = pg_num_fields($this->_resource);
     $oids = array();
     for ($i = 0; $i < $this->_numFields; $i++) {
         $this->_namesHash[pg_field_name($this->_resource, $i)] = $i;
         $oids[$i] = pg_field_type_oid($this->_resource, $i);
     }
     // first set the explicitly given types...
     foreach ($types as $index => $type) {
         $this->setType($index, $type);
     }
     // ...then use type factory to create default converters
     for ($i = 0; $i < $this->_numFields; $i++) {
         if (!isset($this->_converters[$i])) {
             $this->_converters[$i] = $this->_converterFactory->getConverter($oids[$i]);
         }
     }
 }
开发者ID:sad-spirit,项目名称:pg-wrapper,代码行数:33,代码来源:ResultSet.php

示例3: __construct

 public function __construct($result, $bytea_oid)
 {
     $this->result = $result;
     $this->bytea_oid = $bytea_oid;
     // find out if there are any blobs
     $numrows = pg_num_fields($result);
     for ($i = 0; $i < $numrows; $i++) {
         $type_oid = pg_field_type_oid($result, $i);
         if ($type_oid == $this->bytea_oid) {
             $this->blobs[] = pg_field_name($result, $i);
         }
     }
     $this->current = $this->fetch_next();
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:14,代码来源:pgsql_native_moodle_recordset.php

示例4: get_records_sql

 /**
  * Get a number of records as an array of objects using a SQL statement.
  *
  * Return value is like:
  * @see function get_records.
  *
  * @param string $sql the SQL select query to execute. The first column of this SELECT statement
  *   must be a unique value (usually the 'id' field), as it will be used as the key of the
  *   returned array.
  * @param array $params array of sql parameters
  * @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
  * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
  * @return array of objects, or empty array if no records were found
  * @throws dml_exception A DML specific exception is thrown for any errors.
  */
 public function get_records_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0)
 {
     list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum);
     if ($limitfrom or $limitnum) {
         if ($limitnum < 1) {
             $limitnum = "ALL";
         } else {
             if (PHP_INT_MAX - $limitnum < $limitfrom) {
                 // this is a workaround for weird max int problem
                 $limitnum = "ALL";
             }
         }
         $sql .= " LIMIT {$limitnum} OFFSET {$limitfrom}";
     }
     list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
     $this->query_start($sql, $params, SQL_QUERY_SELECT);
     $result = pg_query_params($this->pgsql, $sql, $params);
     $this->query_end($result);
     // find out if there are any blobs
     $numrows = pg_num_fields($result);
     $blobs = array();
     for ($i = 0; $i < $numrows; $i++) {
         $type_oid = pg_field_type_oid($result, $i);
         if ($type_oid == $this->bytea_oid) {
             $blobs[] = pg_field_name($result, $i);
         }
     }
     $rows = pg_fetch_all($result);
     pg_free_result($result);
     $return = array();
     if ($rows) {
         foreach ($rows as $row) {
             $id = reset($row);
             if ($blobs) {
                 foreach ($blobs as $blob) {
                     // note: in PostgreSQL 9.0 the returned blobs are hexencoded by default - see http://www.postgresql.org/docs/9.0/static/runtime-config-client.html#GUC-BYTEA-OUTPUT
                     $row[$blob] = $row[$blob] !== null ? pg_unescape_bytea($row[$blob]) : null;
                 }
             }
             if (isset($return[$id])) {
                 $colname = key($row);
                 debugging("Did you remember to make the first column something unique in your call to get_records? Duplicate value '{$id}' found in column '{$colname}'.", DEBUG_DEVELOPER);
             }
             $return[$id] = (object) $row;
         }
     }
     return $return;
 }
开发者ID:kevin-bruton,项目名称:moodle,代码行数:63,代码来源:pgsql_native_moodle_database.php

示例5: get_records_sql

 /**
  * Get a number of records as an array of objects using a SQL statement.
  *
  * Return value as for @see function get_records.
  *
  * @param string $sql the SQL select query to execute. The first column of this SELECT statement
  *   must be a unique value (usually the 'id' field), as it will be used as the key of the
  *   returned array.
  * @param array $params array of sql parameters
  * @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
  * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
  * @return mixed an array of objects, or empty array if no records were found
  * @throws dml_exception if error
  */
 public function get_records_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0)
 {
     $limitfrom = (int) $limitfrom;
     $limitnum = (int) $limitnum;
     $limitfrom = $limitfrom < 0 ? 0 : $limitfrom;
     $limitnum = $limitnum < 0 ? 0 : $limitnum;
     if ($limitfrom or $limitnum) {
         if ($limitnum < 1) {
             $limitnum = "18446744073709551615";
         }
         $sql .= " LIMIT {$limitnum} OFFSET {$limitfrom}";
     }
     list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
     $this->query_start($sql, $params, SQL_QUERY_SELECT);
     $result = pg_query_params($this->pgsql, $sql, $params);
     $this->query_end($result);
     // find out if there are any blobs
     $numrows = pg_num_fields($result);
     $blobs = array();
     for ($i = 0; $i < $numrows; $i++) {
         $type_oid = pg_field_type_oid($result, $i);
         if ($type_oid == $this->bytea_oid) {
             $blobs[] = pg_field_name($result, $i);
         }
     }
     $rows = pg_fetch_all($result);
     pg_free_result($result);
     $return = array();
     if ($rows) {
         foreach ($rows as $row) {
             $id = reset($row);
             if ($blobs) {
                 foreach ($blobs as $blob) {
                     $row[$blob] = pg_unescape_bytea($row[$blob]);
                 }
             }
             if (isset($return[$id])) {
                 $colname = key($row);
                 debugging("Did you remember to make the first column something unique in your call to get_records? Duplicate value '{$id}' found in column '{$colname}'.", DEBUG_DEVELOPER);
             }
             $return[$id] = (object) $row;
         }
     }
     return $return;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:59,代码来源:pgsql_native_moodle_database.php

示例6: FieldTypeOID

 public function FieldTypeOID($fieldNo)
 {
     return pg_field_type_oid($this->ds, $fieldNo);
 }
开发者ID:raj47i,项目名称:PHP.Fx,代码行数:4,代码来源:pgsqli.php

示例7: getTypeOid

 /**
  * getTypeOid
  *
  * Return the type oid of the given field.
  *
  * @access  public
  * @param   string   $name
  * @throws  FoundationException on error
  * @return  int
  */
 public function getTypeOid($name)
 {
     $ret = pg_field_type_oid($this->handler, $name);
     if ($ret === false) {
         throw new FoundationException(sprintf("Error while fetching type oid for field '%s'.", $name));
     }
     return $ret;
 }
开发者ID:pomm-project,项目名称:foundation,代码行数:18,代码来源:ResultHandler.php

示例8: __construct

 /**
  * Constructor
  *
  * @param resource $result
  * @param array $oids
  */
 public function __construct($result, $oids = null)
 {
     $this->result = $result;
     if ($oids) {
         $this->oidTypeNames = $oids;
     }
     $this->rowCount = pg_num_rows($this->result);
     $this->columnCount = pg_num_fields($this->result);
     if ($this->columnCount) {
         for ($i = 0; $i < $this->columnCount; $i++) {
             $fieldName = pg_field_name($this->result, $i);
             $oid = pg_field_type_oid($this->result, $i);
             $this->columnOids[$fieldName] = $oid;
             $this->columnTypes[$fieldName] = isset($this->oidTypeNames[$oid]) ? $this->oidTypeNames[$oid] : pg_field_type($this->result, $i);
         }
     }
 }
开发者ID:ikitiki,项目名称:pgdb,代码行数:23,代码来源:Result.php


注:本文中的pg_field_type_oid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。