本文整理汇总了PHP中pg_field_size函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_field_size函数的具体用法?PHP pg_field_size怎么用?PHP pg_field_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_field_size函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: query_start
function query_start($query)
{
// For reg expressions
$query = trim($query);
// Query was an insert, delete, update, replace
if (preg_match("/^(insert|delete|update|replace)\\s+/i", $query)) {
return false;
}
// Flush cached values..
$this->flush();
// Log how the function was called
$this->func_call = "\$db->query_start(\"{$query}\")";
// Keep track of the last query for debug..
$this->last_query = $query;
// Perform the query via std pg_query function..
if (!($this->result = @pg_query($this->dbh, $query))) {
$this->print_error();
return false;
}
$this->num_queries++;
// =======================================================
// Take note of column info
$i = 0;
while ($i < @pg_num_fields($this->result)) {
$this->col_info[$i]->name = pg_field_name($this->result, $i);
$this->col_info[$i]->type = pg_field_type($this->result, $i);
$this->col_info[$i]->size = pg_field_size($this->result, $i);
$i++;
}
$this->last_result = array();
$this->num_rows = 0;
// If debug ALL queries
$this->trace || $this->debug_all ? $this->debug() : null;
return true;
}
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:35,代码来源:mtdb_postgres.php
示例2: 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
示例3: getFieldData
/**
* Generates an array of objects representing field meta-data.
*
* @return array
*/
public function getFieldData() : array
{
$retval = [];
for ($i = 0, $c = $this->getFieldCount(); $i < $c; $i++) {
$retval[$i] = new \stdClass();
$retval[$i]->name = pg_field_name($this->resultID, $i);
$retval[$i]->type = pg_field_type($this->resultID, $i);
$retval[$i]->max_length = pg_field_size($this->resultID, $i);
// $retval[$i]->primary_key = (int)($fieldData[$i]->flags & 2);
// $retval[$i]->default = $fieldData[$i]->def;
}
return $retval;
}
开发者ID:titounnes,项目名称:CodeIgniter4,代码行数:18,代码来源:Result.php
示例4: field_structures
/**
* Structure of our fields (type, length and null)
*
* @param resource $resource
* @return array
*/
public function field_structures($resource)
{
$result = [];
if ($resource) {
for ($i = 0; $i < pg_num_fields($resource); $i++) {
$name = pg_field_name($resource, $i);
$result[$name]['type'] = pg_field_type($resource, $i);
$result[$name]['null'] = pg_field_is_null($resource, $i);
$result[$name]['length'] = pg_field_size($resource, $i);
}
}
return $result;
}
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:19,代码来源:base.php
示例5: field_data
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
for ($i = 0; $i < $this->num_fields(); $i++) {
$F = new stdClass();
$F->name = pg_field_name($this->result_id, $i);
$F->type = pg_field_type($this->result_id, $i);
$F->max_length = pg_field_size($this->result_id, $i);
$F->primary_key = 0;
$F->default = '';
$retval[] = $F;
}
return $retval;
}
开发者ID:ayuinc,项目名称:laboratoria-v2,代码行数:22,代码来源:postgre_result.php
示例6: pg_fetch_array
}
for ($i = 0; $i < $rows; $i++) {
pg_fetch_array($result, $i, PGSQL_NUM);
}
for ($i = 0; $i < $rows; $i++) {
pg_fetch_object($result);
}
for ($i = 0; $i < $rows; $i++) {
pg_fetch_row($result, $i);
}
for ($i = 0; $i < $rows; $i++) {
pg_fetch_result($result, $i, 0);
}
pg_result_error($result);
pg_num_rows(pg_execute($db, "php_test", array(100)));
pg_num_fields(pg_execute($db, "php_test", array(100)));
pg_field_name($result, 0);
pg_field_num($result, $field_name);
pg_field_size($result, 0);
pg_field_type($result, 0);
pg_field_prtlen($result, 0);
pg_field_is_null($result, 0);
$result = pg_prepare($db, "php_test2", "INSERT INTO " . $table_name . " VALUES (\$1, \$2);");
pg_result_error($result);
pg_free_result($result);
$result = pg_execute($db, "php_test2", array(9999, "A'BC"));
pg_last_oid($result);
pg_free_result($result);
}
pg_close($db);
echo "OK";
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:24sync_query_prepared.php
示例7: query
function query($query)
{
//去掉查询语句的前后空格
$query = trim($query);
//初始化返回值为0
$return_val = 0;
//清空缓存..
$this->flush();
//记录此函数如何被调用,用于调试...
$this->func_call = "\$db->query(\"{$query}\")";
//跟踪最后查询语句,用于调试..
$this->last_query = $query;
//通过pg_query函数执行查询操作..
if (!($this->result = @pg_query($this->dbh, $query))) {
$this->print_error();
return false;
}
//记录查询次数,用于调试...
$this->num_queries++;
//执行insert, delete, update, replace操作
if (preg_match("/^(insert|delete|update|replace)\\s+/i", $query)) {
//获取操作所影响的记录行数
$this->rows_affected = pg_affected_rows($this->result);
$return_val = $this->rows_affected;
//获取最后插入记录id
if (preg_match("/^(insert)\\s+/i", $query)) {
$this->insert_id = $this->get_insert_id($query);
//$return_val = $this->insert_id;
}
} else {
//获取字段信息
$i = 0;
while ($i < @pg_num_fields($this->result)) {
$this->col_info[$i]->name = pg_field_name($this->result, $i);
$this->col_info[$i]->type = pg_field_type($this->result, $i);
$this->col_info[$i]->size = pg_field_size($this->result, $i);
$i++;
}
//获取查询结果
$i = 0;
while ($row = @pg_fetch_object($this->result, $i)) {
//php5中不支持第三个参数PGSQL_ASSOC?可能已经被删除!但手册上还没有说明。
//取得包含数组的结果对象
$this->last_result[$i] = $row;
$i++;
}
@pg_free_result($this->result);
//获取查询结果行数
$this->num_rows = $i;
$return_val = $this->num_rows;
}
//是否显示所有的查询信息
$this->debug_all ? $this->debug() : null;
return $return_val;
}
开发者ID:chaobj001,项目名称:tt,代码行数:55,代码来源:DBPostgres.class.php
示例8: execute
public function execute($sql)
{
// hide errors
$ini_err = ini_get('display_errors');
ini_set('display_errors', 0);
$res = false;
$this->res_errMsg = null;
// --- process sql
if ($this->dbType == 'postgres') {
$this->res_data = pg_query($this->dbConn, $sql);
if (!$this->res_data) {
$this->res_errMsg = pg_last_error($this->dbConn);
} else {
$this->res_errMsg = pg_result_error($this->res_data);
$this->res_affectedRows = pg_affected_rows($this->res_data);
$this->res_rowCount = pg_num_rows($this->res_data);
$this->res_fieldCount = pg_num_fields($this->res_data);
$res = new dbRecordSet($this->dbType, $this->res_data, $this->res_rowCount, $this->res_fieldCount);
// -- parse field names
for ($i = 0; $i < $this->res_fieldCount; $i++) {
$this->res_fields[$i] = pg_field_name($this->res_data, $i);
$this->res_fieldsInfo[$i] = array();
$this->res_fieldsInfo[$i]['type'] = pg_field_type($this->res_data, $i);
$this->res_fieldsInfo[$i]['len'] = pg_field_size($this->res_data, $i);
$this->res_fieldsInfo[$i]['is_null'] = pg_field_is_null($this->res_data, $i);
$this->res_fieldsInfo[$i]['prt_len'] = pg_field_prtlen($this->res_data, $i);
}
}
// log error
if ($this->res_errMsg != '') {
// put here code to log error
}
}
// --- mysql
if ($this->dbType == 'mysql') {
$this->res_data = mysql_query($sql, $this->dbConn);
if (!$this->res_data) {
$this->res_errMsg = mysql_error($this->dbConn);
} else {
@($this->res_errMsg = mysql_error($this->res_data));
@($this->res_affectedRows = mysql_affected_rows($this->res_data));
@($this->res_rowCount = mysql_num_rows($this->res_data));
@($this->res_fieldCount = mysql_num_fields($this->res_data));
@($res = new dbRecordSet($this->dbType, $this->res_data, $this->res_rowCount, $this->res_fieldCount));
// -- parse field names
for ($i = 0; $i < $this->res_fieldCount; $i++) {
$this->res_fields[$i] = mysql_field_name($this->res_data, $i);
$this->res_fieldsInfo[$i] = array();
$this->res_fieldsInfo[$i]['type'] = mysql_field_type($this->res_data, $i);
$this->res_fieldsInfo[$i]['len'] = mysql_field_len($this->res_data, $i);
$this->res_fieldsInfo[$i]['flags'] = mysql_field_flags($this->res_data, $i);
}
}
// log error
if ($this->res_errMsg != '') {
// put here code to log error
}
}
$this->res_sql = $sql;
// show debug info if on
if ($this->debug == true) {
print "<pre>" . $sql . "<hr>";
if ($this->res_errMsg != '') {
print "<span style='color: red'>" . $this->res_errMsg . "</span><hr>";
}
print "</pre>";
}
// restore errors
ini_set('display_errors', $ini_err);
return $res;
}
开发者ID:LeisureLeo,项目名称:w2ui,代码行数:71,代码来源:w2db.php
示例9: query
function query($query)
{
// For reg expressions
$query = trim($query);
// Flush cached values..
$this->flush();
// Log how the function was called
$this->func_call = "\$db->query(\"{$query}\")";
// Keep track of the last query for debug..
$this->last_query = $query;
// Perform the query via std pg_query function..
if (!($this->result = @pg_query($this->dbh, $query))) {
$this->print_error();
return false;
}
$this->num_queries++;
// If there was an insert, delete or update see how many rows were affected
// (Also, If there there was an insert take note of the last OID
$query_type = array("insert", "delete", "update", "replace");
// loop through the above array
foreach ($query_type as $word) {
// This is true if the query starts with insert, delete or update
if (preg_match("/^{$word}\\s+/i", $query)) {
$this->rows_affected = pg_affected_rows($this->result);
// This gets the insert ID
if ($word == "insert") {
$this->insert_id = $this->get_insert_id($query);
// If insert id then return it - true evaluation
return $this->insert_id;
}
// Set to false if there was no insert id
$this->result = false;
}
}
// In other words if this was a select statement..
if ($this->result) {
// =======================================================
// Take note of column info
$i = 0;
while ($i < @pg_num_fields($this->result)) {
$this->col_info[$i]->name = pg_field_name($this->result, $i);
$this->col_info[$i]->type = pg_field_type($this->result, $i);
$this->col_info[$i]->size = pg_field_size($this->result, $i);
$i++;
}
// =======================================================
// Store Query Results
$i = 0;
while ($i < @pg_num_rows($this->result)) {
$row = @pg_fetch_object($this->result, $i);
// Store relults as an objects within main array
$this->last_result[$i] = $row;
$i++;
}
// Log number of rows the query returned
$this->num_rows = $i;
@pg_free_result($this->result);
// If debug ALL queries
$this->debug_all ? $this->debug() : null;
// If there were results then return true for $db->query
if ($i) {
return true;
} else {
return false;
}
} else {
// If debug ALL queries
$this->debug_all ? $this->debug() : null;
// Update insert etc. was good..
return true;
}
}
开发者ID:benvanstaveren,项目名称:movabletype,代码行数:72,代码来源:ezsql_postgres.php
示例10: field_size
function field_size($result, $fila)
{
if ($size = pg_field_size($result, $fila)) {
return $size;
} else {
return false;
}
}
开发者ID:ricardoletelier,项目名称:conexion-mysqli-postgresql-desde-php,代码行数:8,代码来源:postgres.php
示例11: fieldSize
function fieldSize($rs, $off_set_field)
{
if ($this->bd->sgdb == 'MySQL') {
return mysql_field_len($rs, $off_set_field);
} else {
return pg_field_size($rs, $off_set_field);
}
}
开发者ID:marcioarp,项目名称:marp-framework,代码行数:8,代码来源:connection.php
示例12: fieldSize
/**
* @param int|string $fieldNameOrNum Field name or index.
*
* @return int Storage required for field. -1 indicates a variable length field.
*
* @throws \Icicle\Exception\InvalidArgumentError If the field number does not exist in the result.
*/
public function fieldSize($fieldNameOrNum) : int
{
return \pg_field_size($this->handle, $this->filterNameOrNum($fieldNameOrNum));
}
开发者ID:icicleio,项目名称:postgres,代码行数:11,代码来源:TupleResult.php
示例13: dump
dump( pg_last_oid($result) );
pg_free_result($result);
} elseif( pg_result_status($result) == PGSQL_EMPTY_QUERY ) {
dump( 0 );
dump( 0 );
pg_free_result($result);
} elseif( pg_result_status($result) == PGSQL_TUPLES_OK ) {
$width = pg_num_fields($result);
$height = pg_num_rows($result);
dump($width);
dump($height);
for( $i = 0; $i < $width; ++$i ) {
$type = pg_field_type( $result, $i );
dump( pg_field_name( $result, $i ) );
dump( $type );
dump( pg_field_size( $result, $i ) );
}
for( $i = 0; $i < $height; ++$i ) {
$row = pg_fetch_row( $result );
for( $j = 0; $j < $width; ++$j )
if( is_null($row[$j]) )
dump( '' );
else
dump( ' '.$row[$j] );
}
pg_free_result( $result );
} else {
$e = pg_result_error($result);
pg_free_result($result);
err( $e );
}
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:31,代码来源:emsproxy.php
示例14: fetch_field
/**
* Get column information
* @param int
* @return array
*/
protected function fetch_field($intOffset)
{
$arrData['name'] = @pg_field_name($this->resResult, $intOffset);
$arrData['max_length'] = @pg_field_size($this->resResult, $intOffset);
$arrData['not_null'] = @pg_field_is_null($this->resResult, $intOffset);
$arrData['type'] = @pg_field_type($this->resResult, $intOffset);
return $arrData;
}
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:13,代码来源:DB_Postgresql.php
示例15: fetch_field
function fetch_field(&$result, $i)
{
trigger_before('fetch_field', $this, $this);
$field = new dbfield();
$field->name = pg_field_name($result, $i);
$field->type = pg_field_type($result, $i);
$field->size = pg_field_size($result, $i);
return $field;
}
开发者ID:voitto,项目名称:dbscript,代码行数:9,代码来源:postgresql.php
示例16: FieldSize
public function FieldSize($fieldNo)
{
return pg_field_size($this->ds, $fieldNo);
}
开发者ID:raj47i,项目名称:PHP.Fx,代码行数:4,代码来源:pgsqli.php
示例17: fetch_field
/**
* Get the column information
* @param integer
* @return object
*/
protected function fetch_field($intOffset)
{
$objData = new stdClass();
$objData->name = @pg_field_name($this->resResult, $intOffset);
$objData->max_length = @pg_field_size($this->resResult, $intOffset);
$objData->not_null = @pg_field_is_null($this->resResult, $intOffset);
$objData->type = @pg_field_type($this->resResult, $intOffset);
return $objData;
}
开发者ID:jens-wetzel,项目名称:use2,代码行数:14,代码来源:DB_Postgresql.php
示例18: getColumnsMeta
/**
* Returns metadata for all columns in a result set.
*
* @return array
*/
public function getColumnsMeta()
{
$hasTable = version_compare(PHP_VERSION, '5.2.0', '>=');
$count = pg_num_fields($this->resultSet);
$meta = array();
for ($i = 0; $i < $count; $i++) {
// items 'name' and 'table' are required
$meta[] = array('name' => pg_field_name($this->resultSet, $i), 'table' => $hasTable ? pg_field_table($this->resultSet, $i) : NULL, 'type' => pg_field_type($this->resultSet, $i), 'size' => pg_field_size($this->resultSet, $i), 'prtlen' => pg_field_prtlen($this->resultSet, $i));
}
return $meta;
}
开发者ID:laiello,项目名称:webuntucms,代码行数:16,代码来源:postgre.php
示例19: field_info
function field_info($query, $count)
{
if ($this->debug) {
echo "<pre style=\"color : green\">Getting column information {$this->dbpath} <p style=\"color:purple;\"> {$query} </p></pre>";
}
$nooffields = 0;
//Validate the sql statement and make adjustments
switch ($this->dbtype) {
/* Firebird Functionality */
case "firebird":
//write some things here
$col_info = ibase_field_info($query, $count);
break;
/* SQLite Functionality */
/* SQLite Functionality */
case "sqlite":
putenv("TMP=" . $this->tmppath);
$name = sqlite_field_name($query, $count);
//echo $name;
$col_info["alias"] = $name;
$col_info["name"] = $name;
break;
/* Oracle Functionality */
/* Oracle Functionality */
case "oracle":
$column_name = oci_field_name($query, $count);
$column_type = oci_field_type($query, $count);
$column_size = oci_field_size($query, $count);
$column_prec = oci_field_precision($query, $count);
$column_scale = oci_field_scale($query, $count);
$col_info["name"] = $column_name;
$col_info["alias"] = $column_name;
$col_info["length"] = $column_size;
$col_info["prec"] = $column_prec;
$col_info["type"] = $column_type;
$col_info["scale"] = $column_scale;
break;
/* PGSQL Functionality */
/* PGSQL Functionality */
case "pgsql":
$col_info["name"] = pg_field_name($query, $count);
$col_info["alias"] = NULL;
// always set to NULL
$col_info["relation"] = NULL;
// always set to NULL
$col_info["length"] = pg_field_size($query, $count);
$col_info["type"] = pg_field_type($query, $count);
break;
}
if ($this->debug) {
echo "<pre style=\"color : blue\">Column Info fetched for Column {$count} \n </pre>";
}
return $col_info;
}
开发者ID:mortalerror,项目名称:ultimatesims,代码行数:54,代码来源:cdeclass.php
示例20: tableInfo
/**
* Returns information about a table or a result set
*
* NOTE: only supports 'table' and 'flags' if <var>$result</var>
* is a table name.
*
* @param object|string $result MDB2_result object from a query or a
* string containing the name of a table.
* While this also accepts a query result
* resource identifier, this behavior is
* deprecated.
* @param int $mode a valid tableInfo mode
*
* @return array an associative array with the information requested.
* A MDB2_Error object on failure.
*
* @see MDB2_Driver_Common::tableInfo()
*/
function tableInfo($result, $mode = null)
{
if (is_string($result)) {
return parent::tableInfo($result, $mode);
}
$db =& $this->getDBInstance();
if (PEAR::isError($db)) {
return $db;
}
$resource = MDB2::isResultCommon($result) ? $result->getResource() : $result;
if (!is_resource($resource)) {
return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'Could not generate result resource', __FUNCTION__);
}
if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
if ($db->options['field_case'] == CASE_LOWER) {
$case_func = 'strtolower';
} else {
$case_func = 'strtoupper';
}
} else {
$case_func = 'strval';
}
$count = @pg_num_fields($resource);
$res = array();
if ($mode) {
$res['num_fields'] = $count;
}
$db->loadModule('Datatype', null, true);
for ($i = 0; $i < $count; $i++) {
$res[$i] = array('table' => function_exists('pg_field_table') ? @pg_field_table($resource, $i) : '', 'name' => $case_func(@pg_field_name($resource, $i)), 'type' => @pg_field_type($resource, $i), 'length' => @pg_field_size($resource, $i), 'flags' => '');
$mdb2type_info = $db->datatype->mapNativeDatatype($res[$i]);
if (PEAR::isError($mdb2type_info)) {
return $mdb2type_info;
}
$res[$i]['mdb2type'] = $mdb2type_info[0][0];
if ($mode & MDB2_TABLEINFO_ORDER) {
$res['order'][$res[$i]['name']] = $i;
}
if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
$res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
}
}
return $res;
}
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:62,代码来源:pgsql.php
注:本文中的pg_field_size函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论