本文整理汇总了PHP中pg_fieldsize函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_fieldsize函数的具体用法?PHP pg_fieldsize怎么用?PHP pg_fieldsize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_fieldsize函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 DB_result object from a query or a
* string containing the name of a table
* @param int $mode a valid tableInfo mode
* @return array an associative array with the information requested
* or an error object if something is wrong
* @access public
* @internal
* @see DB_common::tableInfo()
*/
function tableInfo($result, $mode = null)
{
if (isset($result->result)) {
/*
* Probably received a result object.
* Extract the result resource identifier.
*/
$id = $result->result;
$got_string = false;
} elseif (is_string($result)) {
/*
* Probably received a table name.
* Create a result resource identifier.
*/
$id = @pg_exec($this->connection, "SELECT * FROM {$result} LIMIT 0");
$got_string = true;
} else {
/*
* Probably received a result resource identifier.
* Copy it.
* Deprecated. Here for compatibility only.
*/
$id = $result;
$got_string = false;
}
if (!is_resource($id)) {
return $this->pgsqlRaiseError(DB_ERROR_NEED_MORE_DATA);
}
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
$case_func = 'strtolower';
} else {
$case_func = 'strval';
}
$count = @pg_numfields($id);
// made this IF due to performance (one if is faster than $count if's)
if (!$mode) {
for ($i = 0; $i < $count; $i++) {
$res[$i]['table'] = $got_string ? $case_func($result) : '';
$res[$i]['name'] = $case_func(@pg_fieldname($id, $i));
$res[$i]['type'] = @pg_fieldtype($id, $i);
$res[$i]['len'] = @pg_fieldsize($id, $i);
$res[$i]['flags'] = $got_string ? $this->_pgFieldflags($id, $i, $result) : '';
}
} else {
// full
$res['num_fields'] = $count;
for ($i = 0; $i < $count; $i++) {
$res[$i]['table'] = $got_string ? $case_func($result) : '';
$res[$i]['name'] = $case_func(@pg_fieldname($id, $i));
$res[$i]['type'] = @pg_fieldtype($id, $i);
$res[$i]['len'] = @pg_fieldsize($id, $i);
$res[$i]['flags'] = $got_string ? $this->_pgFieldFlags($id, $i, $result) : '';
if ($mode & DB_TABLEINFO_ORDER) {
$res['order'][$res[$i]['name']] = $i;
}
if ($mode & DB_TABLEINFO_ORDERTABLE) {
$res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
}
}
}
// free the result only if we were called on a table
if ($got_string) {
@pg_freeresult($id);
}
return $res;
}
示例2: ADOFieldObject
function &FetchField($off = 0)
{
// offsets begin at 0
$o = new ADOFieldObject();
$o->name = @pg_fieldname($this->_queryID, $off);
$o->type = @pg_fieldtype($this->_queryID, $off);
$o->max_length = @pg_fieldsize($this->_queryID, $off);
return $o;
}
示例3: tableInfo
/**
* Returns information about a table or a result set
*
* NOTE: doesn't support table name and flags if called from a db_result
*
* @param mixed $resource PostgreSQL result identifier or table name
* @param int $mode A valid tableInfo mode (DB_TABLEINFO_ORDERTABLE or
* DB_TABLEINFO_ORDER)
*
* @return array An array with all the information
*/
function tableInfo($result, $mode = null)
{
$count = 0;
$id = 0;
$res = array();
/*
* depending on $mode, metadata returns the following values:
*
* - mode is false (default):
* $result[]:
* [0]["table"] table name
* [0]["name"] field name
* [0]["type"] field type
* [0]["len"] field length
* [0]["flags"] field flags
*
* - mode is DB_TABLEINFO_ORDER
* $result[]:
* ["num_fields"] number of metadata records
* [0]["table"] table name
* [0]["name"] field name
* [0]["type"] field type
* [0]["len"] field length
* [0]["flags"] field flags
* ["order"][field name] index of field named "field name"
* The last one is used, if you have a field name, but no index.
* Test: if (isset($result['meta']['myfield'])) { ...
*
* - mode is DB_TABLEINFO_ORDERTABLE
* the same as above. but additionally
* ["ordertable"][table name][field name] index of field
* named "field name"
*
* this is, because if you have fields from different
* tables with the same field name * they override each
* other with DB_TABLEINFO_ORDER
*
* you can combine DB_TABLEINFO_ORDER and
* DB_TABLEINFO_ORDERTABLE with DB_TABLEINFO_ORDER |
* DB_TABLEINFO_ORDERTABLE * or with DB_TABLEINFO_FULL
*/
// if $result is a string, then we want information about a
// table without a resultset
if (is_string($result)) {
$id = pg_exec($this->connection, "SELECT * FROM {$result}");
if (empty($id)) {
return $this->pgsqlRaiseError();
}
} else {
// else we want information about a resultset
$id = $result;
if (empty($id)) {
return $this->pgsqlRaiseError();
}
}
$count = @pg_numfields($id);
// made this IF due to performance (one if is faster than $count if's)
if (empty($mode)) {
for ($i = 0; $i < $count; $i++) {
$res[$i]['table'] = is_string($result) ? $result : '';
$res[$i]['name'] = @pg_fieldname($id, $i);
$res[$i]['type'] = @pg_fieldtype($id, $i);
$res[$i]['len'] = @pg_fieldsize($id, $i);
$res[$i]['flags'] = is_string($result) ? $this->_pgFieldflags($id, $i, $result) : '';
}
} else {
// full
$res["num_fields"] = $count;
for ($i = 0; $i < $count; $i++) {
$res[$i]['table'] = is_string($result) ? $result : '';
$res[$i]['name'] = @pg_fieldname($id, $i);
$res[$i]['type'] = @pg_fieldtype($id, $i);
$res[$i]['len'] = @pg_fieldsize($id, $i);
$res[$i]['flags'] = is_string($result) ? $this->_pgFieldFlags($id, $i, $result) : '';
if ($mode & DB_TABLEINFO_ORDER) {
$res['order'][$res[$i]['name']] = $i;
}
if ($mode & DB_TABLEINFO_ORDERTABLE) {
$res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
}
}
}
// free the result only if we were called on a table
if (is_resource($id)) {
@pg_freeresult($id);
}
return $res;
}
示例4: ADOFieldObject
function &FetchField($fieldOffset = 0)
{
$off = $fieldOffset;
// offsets begin at 0
$o = new ADOFieldObject();
$o->name = @pg_fieldname($this->_queryID, $off);
$o->type = @pg_fieldtype($this->_queryID, $off);
$o->max_length = @pg_fieldsize($this->_queryID, $off);
//print_r($o);
//print "off=$off name=$o->name type=$o->type len=$o->max_length<br>";
return $o;
}
示例5: dimcampo_query
function dimcampo_query($query, $num)
{
$risul = pg_fieldsize($query, $num);
return $risul;
}
示例6: pg_connect
<?php
include 'config.inc';
$db = pg_connect($conn_str);
$result = pg_exec("SELECT * FROM " . $table_name);
pg_numrows($result);
pg_numfields($result);
pg_fieldname($result, 0);
pg_fieldsize($result, 0);
pg_fieldtype($result, 0);
pg_fieldprtlen($result, 0);
pg_fieldisnull($result, 0);
pg_result($result, 0, 0);
$result = pg_exec("INSERT INTO " . $table_name . " VALUES (7777, 'KKK')");
$oid = pg_getlastoid($result);
pg_freeresult($result);
pg_errormessage();
$result = pg_exec("UPDATE " . $table_name . " SET str = 'QQQ' WHERE str like 'RGD';");
pg_cmdtuples($result);
echo "OK";
示例7: FieldLength
function FieldLength($result, $offset)
{
switch ($this->dbType) {
case "mssql":
$r = mssql_field_length($result, $offset);
break;
case "mysql":
$r = mysql_field_len($result, $offset);
break;
case "pg":
$r = pg_fieldsize($result, $offset);
break;
default:
$r = False;
break;
}
return $r;
}
示例8: pg_exec
</th>
<th><?php
echo $strType;
?>
</th>
<th><?php
echo $strValue;
?>
</th>
</tr>
<?php
$result = pg_exec($link, pre_query($sql_get_fields));
for ($i = 0; $i < pg_numfields($result); $i++) {
$field = pg_fieldname($result, $i);
$type = pg_fieldtype($result, $i);
$len = pg_fieldsize($result, $i);
if ($len < 1) {
$len_disp = "var";
$len = 50;
} else {
$len_disp = $len;
}
$bgcolor = $cfgBgcolorOne;
$i % 2 ? 0 : ($bgcolor = $cfgBgcolorTwo);
echo "<tr bgcolor=" . $bgcolor . ">";
echo "<td>{$field}</td>";
echo "<td>{$type} ({$len_disp})</td>";
if ($type == "bool") {
echo "<td><select name=fields[]><option value=\"t\">True<option value=\"f\">False</select></td>";
} else {
echo "<td><input type=text name=fields[] style=\"width: " . $cfgMaxInputsize . "\" maxlength=" . $len . "></td>\n";
示例9: 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
* @param int $mode a valid tableInfo mode
* @return array an associative array with the information requested
* or an error object if something is wrong
* @access public
* @internal
* @see MDB2_Driver_Common::tableInfo()
*/
function tableInfo($result, $mode = null)
{
$db =& $GLOBALS['_MDB2_databases'][$this->db_index];
if ($db->options['portability'] & MDB2_PORTABILITY_LOWERCASE) {
$case_func = 'strtolower';
} else {
$case_func = 'strval';
}
if (is_string($result)) {
/*
* Probably received a table name.
* Create a result resource identifier.
*/
if (MDB2::isError($connect = $db->connect())) {
return $connect;
}
$id = @pg_exec($db->connection, "SELECT * FROM {$result} LIMIT 0");
$got_string = true;
} else {
/*
* Probably received a result object.
* Extract the result resource identifier.
*/
$id = $result->getResource();
if (empty($id)) {
return $db->raiseError();
}
$got_string = false;
}
if (!is_resource($id)) {
return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA);
}
$count = @pg_numfields($id);
// made this IF due to performance (one if is faster than $count if's)
if (!$mode) {
for ($i = 0; $i < $count; $i++) {
$res[$i]['table'] = $got_string ? $case_func($result) : '';
$res[$i]['name'] = $case_func(@pg_fieldname($id, $i));
$res[$i]['type'] = @pg_fieldtype($id, $i);
$res[$i]['len'] = @pg_fieldsize($id, $i);
$res[$i]['flags'] = $got_string ? $this->_pgFieldflags($id, $i, $result) : '';
}
} else {
// full
$res['num_fields'] = $count;
for ($i = 0; $i < $count; $i++) {
$res[$i]['table'] = $got_string ? $case_func($result) : '';
$res[$i]['name'] = $case_func(@pg_fieldname($id, $i));
$res[$i]['type'] = @pg_fieldtype($id, $i);
$res[$i]['len'] = @pg_fieldsize($id, $i);
$res[$i]['flags'] = $got_string ? $this->_pgFieldFlags($id, $i, $result) : '';
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;
}
}
}
// free the result only if we were called on a table
if ($got_string) {
@pg_freeresult($id);
}
return $res;
}