本文整理汇总了PHP中db2_num_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP db2_num_fields函数的具体用法?PHP db2_num_fields怎么用?PHP db2_num_fields使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db2_num_fields函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: columnCount
/**
* {@inheritdoc}
*/
public function columnCount()
{
if (!$this->_stmt) {
return false;
}
return db2_num_fields($this->_stmt);
}
示例2: _initrs
function _initrs()
{
global $ADODB_COUNTRECS;
$this->_numOfRows = $ADODB_COUNTRECS ? @db2_num_rows($this->_queryID) : -1;
$this->_numOfFields = @db2_num_fields($this->_queryID);
// some silly drivers such as db2 as/400 and intersystems cache return _numOfRows = 0
if ($this->_numOfRows == 0) {
$this->_numOfRows = -1;
}
}
示例3: _execute
/**
* Executes given SQL statement. We should use prepare / execute to allow the
* database server to reuse its access plan and increase the efficiency
* of your database access
*
* @param string $sql SQL statement
* @return resource Result resource identifier
* @access protected
*/
function _execute($sql)
{
// get result from db
$result = db2_exec($this->connection, $sql);
if (!is_bool($result)) {
// build table/column map for this result
$map = array();
$numFields = db2_num_fields($result);
$index = 0;
$j = 0;
$offset = 0;
while ($j < $numFields) {
$columnName = strtolower(db2_field_name($result, $j));
$tmp = strpos($sql, '.' . $columnName, $offset);
$tableName = substr($sql, $offset, $tmp - $offset);
$tableName = substr($tableName, strrpos($tableName, ' ') + 1);
$map[$index++] = array($tableName, $columnName);
$j++;
$offset = strpos($sql, ' ', $tmp);
}
$this->_resultMap[$result] = $map;
}
return $result;
}
示例4: otherdb
//.........这里部分代码省略.........
<div class="actall">Host:<input type="text" name="db2host" value="{$db2host}" style="width:100px">
Port:<input type="text" name="db2port" value="{$db2port}" style="width:60px">
User:<input type="text" name="db2user" value="{$db2user}" style="width:100px">
Pass:<input type="text" name="db2pass" value="{$db2pass}" style="width:100px">
Dbname:<input type="text" name="db2dbname" value="{$db2dbname}" style="width:100px"><br>
<script language="javascript">
function db2Full(i){
Str = new Array(4);
\tStr[0] = "";
\tStr[1] = "select schemaname from syscat.schemata;";
\tStr[2] = "select name from sysibm.systables;";
\tStr[3] = "select colname from syscat.columns where tabname='table_name';";
\tStr[4] = "db2 get db cfg for db_name;";
db2form.db2sql.value = Str[i];
return true;
}
</script>
<textarea name="db2sql" style="width:600px;height:200px;">{$db2query}</textarea><br>
<select onchange="return db2Full(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">���ݿ�</option>
\t<option value="1">����</option>
\t<option value="2">�ֶ�</option>
\t<option value="3">���ݿ�����</option>
</select>
<input type="hidden" name="action" value="db2query">
<input class="bt" type="submit" value="Query"></div></form>
END;
if ($myaction == 'db2query') {
$db2link = db2_connect($db2dbname, $db2user, $db2pass) or die(db2_conn_errormsg());
$db2result = db2_exec($db2link, $db2query) or die(db2_stmt_errormsg());
$db2row = db2_fetch_row($db2result);
echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td><b>' . db2_field_name($db2result) . "</b></td>\n";
}
echo "</tr>\n";
while ($db2row = db2_fetch_row($db2result)) {
echo "<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td>' . "{$db2row[$i]}" . '</td>';
}
echo "</tr>\n";
}
echo "</table></font>";
db2_free_result($db2result);
db2_close();
}
} elseif ($db == "fb") {
$fbhost = isset($_POST['fbhost']) ? $_POST['fbhost'] : 'localhost';
$fbpath = isset($_POST['fbpath']) ? $_POST['fbpath'] : '';
$fbpath = str_replace("\\\\", "\\", $fbpath);
$fbuser = isset($_POST['fbuser']) ? $_POST['fbuser'] : 'sysdba';
$fbpass = isset($_POST['fbpass']) ? $_POST['fbpass'] : 'masterkey';
$fbaction = isset($_POST['action']) ? $_POST['action'] : '';
$fbquery = isset($_POST['fbsql']) ? $_POST['fbsql'] : '';
$fbquery = stripslashes($fbquery);
print <<<END
<form method="POST" name="fbform" action="?s=gg&db=fb">
<div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px">
Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px">
User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px">
Pass:<input type="text" name="fbpass" value="{$fbpass}" style="width:100px"><br/>
<script language="javascript">
function fbFull(i){
Str = new Array(5);
示例5: getFieldCount
/**
* Get field count
*
* @return integer
*/
public function getFieldCount()
{
return db2_num_fields($this->resource);
}
示例6: numFields
/**
* Returns the number of columns in a resource
* @param $res Object: statement resource
* @return Number of fields/columns in resource
*/
public function numFields($res)
{
if ($res instanceof ResultWrapper) {
$res = $res->result;
}
if ($res instanceof IBM_DB2Result) {
$res = $res->getResult();
}
return db2_num_fields($res);
}
示例7: columnCount
public static function columnCount($rs)
{
if ($rs) {
return db2_num_fields($rs);
} else {
return 0;
}
}
示例8: getFieldsArray
public function getFieldsArray($result, $make_lower_case = false)
{
if (!isset($result) || empty($result)) {
return 0;
}
$field_array = array();
$count = db2_num_fields($result);
for ($i = 0; $i < $count; $i++) {
$meta = db2_field_name($result, $i);
if (!$meta) {
return array();
}
$field_array[] = $make_lower_case ? strtolower($meta) : $meta;
}
return $field_array;
}
示例9: otherdb
//.........这里部分代码省略.........
Pass:<input type="text" name="db2pass" value="{$db2pass}" style="width:100px">
Dbname:<input type="text" name="db2dbname" value="{$db2dbname}" style="width:100px"><br><br>
<script language="javascript">
function db2Full(i){
\tStr = new Array(4);
Str[0] = "";
\tStr[1] = "select schemaname from syscat.schemata;";
Str[2] = "select name from sysibm.systables;";
Str[3] = "select colname from syscat.columns where tabname='table_name';";
Str[4] = "db2 get db cfg for db_name;";
\tdb2form.db2sql.value = Str[i];
\treturn true;
}
</script>
<textarea name="db2sql" style="width:600px;height:200px;">{$db2query}</textarea><br>
<select onchange="return db2Full(options[selectedIndex].value)">
\t<option value="0" selected>command</option>
<option value="1">databases</option>
<option value="1">tables</option>
<option value="2">columns</option>
<option value="3">db config</option>
</select>
<input type="hidden" name="action" value="db2query">
<input class="bt" type="submit" value="Query"></div></form>
END;
if ($myaction == 'db2query') {
//$db2string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$db2dbname;"."HOSTNAME=$db2host;PORT=$db2port;PROTOCOL=TCPIP;UID=$db2user;PWD=$db2pass;";
$db2link = db2_connect($db2dbname, $db2user, $db2pass) or die(db2_conn_errormsg());
$db2result = db2_exec($db2link, $db2query) or die(db2_stmt_errormsg());
$db2row = db2_fetch_row($db2result);
echo '<font face="verdana">';
echo '<table border="1" cellpadding="1" cellspacing="2">';
echo "\n<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td bgcolor="#228B22"><b>' . db2_field_name($db2result);
echo "</b></td>\n";
}
echo "</tr>\n";
while ($db2row = db2_fetch_row($db2result)) {
echo "<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td bgcolor="#B8B8E8">';
echo "{$db2row[$i]}";
echo '</td>';
}
echo "</tr>\n";
}
echo "</table>\n";
echo "</font>";
db2_free_result($db2result);
db2_close();
}
} elseif ($db == "fb") {
$fbhost = isset($_POST['fbhost']) ? $_POST['fbhost'] : 'localhost';
$fbpath = isset($_POST['fbpath']) ? $_POST['fbpath'] : '';
$fbpath = str_replace("\\\\", "\\", $fbpath);
$fbuser = isset($_POST['fbuser']) ? $_POST['fbuser'] : 'sysdba';
$fbpass = isset($_POST['fbpass']) ? $_POST['fbpass'] : 'masterkey';
$fbaction = isset($_POST['action']) ? $_POST['action'] : '';
$fbquery = isset($_POST['fbsql']) ? $_POST['fbsql'] : '';
$fbquery = stripslashes($fbquery);
print <<<END
<form method="POST" name="fbform" action="?s=w&db=fb">
<div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px">
Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px">
User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px">
示例10: sqlqu
function sqlqu($sqlty, $host, $user, $pass, $db = '', $query)
{
$res = '';
switch ($sqlty) {
case 'MySQL':
if (!function_exists('mysql_connect')) {
return 0;
}
$link = @mysql_connect($host, $user, $pass);
if ($link) {
if (!empty($db)) {
@mysql_select_db($db, $link);
}
$result = @mysql_query($query, $link);
if ($result != 1) {
while ($data = @mysql_fetch_row($result)) {
$res .= implode('+', $data) . '-+';
}
$res .= '*';
for ($i = 0; $i < @mysql_num_fields($result); $i++) {
$res .= @mysql_field_name($result, $i) . '-';
}
}
@mysql_close($link);
return $res;
}
break;
case 'MSSQL':
if (!function_exists('mssql_connect')) {
return 0;
}
$link = @mssql_connect($host, $user, $pass);
if ($link) {
if (!empty($db)) {
@mssql_select_db($db, $link);
}
$result = @mssql_query($query, $link);
while ($data = @mssql_fetch_row($result)) {
$res .= implode('+', $data) . '-+';
}
$res .= '*';
for ($i = 0; $i < @mssql_num_fields($result); $i++) {
$res .= @mssql_field_name($result, $i) . '-';
}
@mssql_close($link);
return $res;
}
break;
case 'Oracle':
if (!function_exists('ocilogon')) {
return 0;
}
$link = @ocilogon($user, $pass, $db);
if ($link) {
$stm = @ociparse($link, $query);
@ociexecute($stm, OCI_DEFAULT);
while ($data = @ocifetchinto($stm, $data, OCI_ASSOC + OCI_RETURN_NULLS)) {
$res .= implode('+', $data) . '-+';
}
$res .= '*';
for ($i = 0; $i < oci_num_fields($stm); $i++) {
$res .= @oci_field_name($stm, $i) . '-';
}
return $res;
}
break;
case 'PostgreSQL':
if (!function_exists('pg_connect')) {
return 0;
}
$link = @pg_connect("host={$host} dbname={$db} user={$user} password={$pass}");
if ($link) {
$result = @pg_query($link, $query);
while ($data = @pg_fetch_row($result)) {
$res .= implode('+', $data) . '-+';
}
$res .= '*';
for ($i = 0; $i < @pg_num_fields($result); $i++) {
$res .= @pg_field_name($result, $i) . '-';
}
@pg_close($link);
return $res;
}
break;
case 'DB2':
if (!function_exists('db2_connect')) {
return 0;
}
$link = @db2_connect($db, $user, $pass);
if ($link) {
$result = @db2_exec($link, $query);
while ($data = @db2_fetch_row($result)) {
$res .= implode('+', $data) . '-+';
}
$res .= '*';
for ($i = 0; $i < @db2_num_fields($result); $i++) {
$res .= @db2_field_name($result, $i) . '-';
}
@db2_close($link);
return $res;
//.........这里部分代码省略.........
示例11: set_num_fields
public function set_num_fields()
{
$this->num_fields = db2_num_fields($this->resource);
}
示例12: getLength
/**
* Get length of result returned from query
*
* @return int
*/
public function getLength()
{
switch ($this->model) {
case "MYSQLI":
$return = $this->raw_data->num_rows;
break;
case "MYSQL_PDO":
case "SQLITE_PDO":
case "ORACLE_PDO":
case "DBLIB_PDO":
if (is_null($this->data)) {
$this->getData();
}
$return = count($this->data);
break;
case "DB2":
$return = db2_num_fields($this->raw_data);
break;
case "POSTGRESQL":
$return = pg_num_rows($this->raw_data);
break;
}
return $return;
}
示例13: resultsToArray
//.........这里部分代码省略.........
$this->rows = $data->rowCount();
break;
case "ORACLE_PDO":
if (!is_object($data)) {
throw new DatabaseException('Invalid result data for model ' . $this->model);
}
switch ($this->fetch) {
case 'NUM':
$fetch = \PDO::FETCH_NUM;
break;
case 'ASSOC':
$fetch = \PDO::FETCH_ASSOC;
break;
default:
$fetch = \PDO::FETCH_BOTH;
break;
}
$result = $data->fetchAll($fetch);
$this->length = sizeof($result);
$this->rows = $data->rowCount();
try {
$this->id = $this->oracleLastInsertId();
} catch (DatabaseException $de) {
throw $de;
}
break;
case "DBLIB_PDO":
if (!is_object($data)) {
throw new DatabaseException('Invalid result data for model ' . $this->model);
}
switch ($this->fetch) {
case 'NUM':
$fetch = \PDO::FETCH_NUM;
break;
case 'ASSOC':
$fetch = \PDO::FETCH_ASSOC;
break;
default:
$fetch = \PDO::FETCH_BOTH;
break;
}
$result = $data->fetchAll($fetch);
$this->length = sizeof($result);
$this->rows = $data->rowCount();
try {
$this->id = $this->dblibLastInsertId();
} catch (DatabaseException $de) {
throw $de;
}
break;
case "DB2":
if (!is_resource($data) or @get_resource_type($data) != "DB2 Statement") {
throw new DatabaseException('Invalid result data for model ' . $this->model);
}
$this->length = db2_num_fields($data);
$this->id = db2_last_insert_id($this->dbh);
$this->rows = db2_num_rows($data);
switch ($this->fetch) {
case 'NUM':
while ($row = db2_fetch_row($data)) {
array_push($result, $row);
}
break;
case 'ASSOC':
while ($row = db2_fetch_assoc($data)) {
array_push($result, $row);
}
break;
default:
while ($row = db2_fetch_both($data)) {
array_push($result, $row);
}
break;
}
break;
case "POSTGRESQL":
if (!is_resource($data) or @get_resource_type($data) != "pgsql result") {
throw new DatabaseException('Invalid result data for model ' . $this->model);
}
$this->length = pg_num_rows($data);
$this->id = pg_last_oid($data);
$this->rows = pg_affected_rows($data);
while ($iterator < $this->length) {
switch ($this->fetch) {
case 'NUM':
$result[$iterator] = pg_fetch_array($data);
break;
case 'ASSOC':
$result[$iterator] = pg_fetch_assoc($data);
break;
default:
$result[$iterator] = pg_fetch_all($data);
break;
}
$iterator++;
}
break;
}
return array("data" => $result, "length" => $this->length, "id" => $this->id, "affected_rows" => $this->rows);
}