本文整理汇总了PHP中pg_field_size函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_field_size函数的具体用法?PHP pg_field_size怎么用?PHP pg_field_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_field_size函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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";
示例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;
}
示例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;
}
示例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;
}
}
示例10: field_size
function field_size($result, $fila)
{
if ($size = pg_field_size($result, $fila)) {
return $size;
} else {
return false;
}
}
示例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);
}
}
示例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));
}
示例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 );
}
示例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;
}
示例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;
}