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


PHP db2_fetch_array函数代码示例

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


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

示例1: select

 function select()
 {
     $conn = $this->connect();
     if ($conn == true) {
         $sql = "SELECT name from helloworld";
         $result = db2_exec($conn, $sql);
         while ($row = db2_fetch_array($result)) {
             echo $text = $row[0];
         }
     }
 }
开发者ID:ab-k,项目名称:phresco,代码行数:11,代码来源:db2.php

示例2: dbQuery

function dbQuery($query, $show_errors = true, $all_results = true, $show_output = true)
{
    if ($show_errors) {
        error_reporting(E_ALL);
    } else {
        error_reporting(E_PARSE);
    }
    // Connect to the IBM DB2 database management system
    $link = db2_pconnect("testdb", "db2inst1", "testpass");
    if (!$link) {
        die(db2_conn_errormsg());
    }
    // Print results in HTML
    print "<html><body>\n";
    // Print SQL query to test sqlmap '--string' command line option
    //print "<b>SQL query:</b> " . $query . "<br>\n";
    // Perform SQL injection affected query
    $stmt = db2_prepare($link, $query);
    $result = db2_execute($stmt);
    if (!$result) {
        if ($show_errors) {
            print "<b>SQL error:</b> " . db2_stmt_errormsg($stmt) . "<br>\n";
        }
        exit(1);
    }
    if (!$show_output) {
        exit(1);
    }
    print "<b>SQL results:</b>\n";
    print "<table border=\"1\">\n";
    while ($line = db2_fetch_array($stmt)) {
        print "<tr>";
        foreach ($line as $col_value) {
            print "<td>" . $col_value . "</td>";
        }
        print "</tr>\n";
        if (!$all_results) {
            break;
        }
    }
    print "</table>\n";
    print "</body></html>";
}
开发者ID:dieface,项目名称:testenv,代码行数:43,代码来源:db2.inc.php

示例3: selectDb

 /**
  * Performs a SQL statement in database and returns rows.
  *
  * @param unknown $sql
  *        	the SQL statement.
  * @throws Exception
  * @return multitype:
  */
 public function selectDb($sql)
 {
     $rowArr = array();
     $connection = $this->connect();
     $stmt = db2_prepare($connection, $sql);
     $result = db2_execute($stmt);
     if ($result) {
         // echo "Result Set created.\n";
         while ($row = db2_fetch_array($stmt)) {
             array_push($rowArr, $row);
         }
     } else {
         // echo "Result Set not created.\n";
         $message = "\nCould not select from database table. " . db2_stmt_errormsg($stmt);
         throw new Exception($message);
     }
     $this->__destruct();
     return $rowArr;
 }
开发者ID:josivansilva,项目名称:php-samples,代码行数:27,代码来源:BaseDAO.php

示例4: session_unset

session_unset();
error_reporting(0);
session_start();
include 'connect.php';
if (isset($_POST['userName']) && isset($_POST['password'])) {
    $usernameEntered = $_POST['userName'];
    $passwordEntered = $_POST['password'];
    $conn = db2_connect($database, $dbusername, $dbpassword);
    $sqlquery = "SELECT password FROM OWNER.USERS WHERE email = '{$usernameEntered}' ";
    $stmt = db2_prepare($conn, $sqlquery);
    if ($stmt) {
        $result = db2_execute($stmt);
        if (!$result) {
            db2_stmt_errormsg($stmt);
        }
        while ($row = db2_fetch_array($stmt)) {
            $passwordFromDb = $row[0];
        }
        db2_close($conn);
        echo $passwordFromDb;
        if ($passwordEntered == $passwordFromDb) {
            $_SESSION['username'] = $usernameEntered;
            header('Location: nav.php');
        } else {
            header('Location: login.php');
        }
    }
} else {
    http_response_code(400);
}
开发者ID:anhhng,项目名称:AuctionHub,代码行数:30,代码来源:log-in.php

示例5: __construct

 /**
  * Constructor for simpledb Proxy
  * Use the values from the configuration file provided to create a PDO for the database
  * Query the database to obtain column metadata and primary key
  *
  * @param string $target                     Target
  * @param string $immediate_caller_directory Directory
  * @param string $binding_config             Config
  */
 public function __construct($target, $immediate_caller_directory, $binding_config)
 {
     SCA::$logger->log('Entering constructor');
     try {
         $this->table = $target;
         $this->config = SCA_Helper::mergeBindingIniAndConfig($binding_config, $immediate_caller_directory);
         if (array_key_exists('username', $this->config)) {
             $username = $this->config['username'];
         } else {
             $username = null;
         }
         if (array_key_exists('password', $this->config)) {
             $password = $this->config['password'];
         } else {
             $password = null;
         }
         if (array_key_exists('namespace', $this->config)) {
             $this->namespace = $this->config['namespace'];
         }
         if (array_key_exists('case', $this->config)) {
             $this->case = $this->config['case'];
         } else {
             $this->case = 'lower';
         }
         if (!array_key_exists('dsn', $this->config)) {
             throw new SCA_RuntimeException("Data source name should be specified");
         }
         $tableName = $this->table;
         // Special processing for IBM databases:
         // IBM table names can contain schema name as prefix
         // Column metadata returned by pdo_ibm does not specify the primary key
         // Hence primary key for IBM databases has to be obtained using
         // db2_primary_key.
         if (strpos($this->config["dsn"], "ibm:") === 0 || strpos($this->config["dsn"], "IBM:") === 0) {
             $this->isIBM = true;
             // Table could be of format schemaName.tableName
             $schemaName = null;
             if (($pos = strrpos($tableName, '.')) !== false) {
                 $schemaName = substr($tableName, 0, $pos);
                 $tableName = substr($tableName, $pos + 1);
             }
             // DSN for IBM databases can be a database name or a connection string
             // Both can be passed onto db2_connect. Remove the dsn prefix if specified
             $database = substr($this->config["dsn"], 4);
             if (strpos($database, "dsn=") === 0 || strpos($database, "DSN=") === 0) {
                 $database = substr($database, 4);
             }
             // Need to make sure the name is in DB2 uppercase style
             $db2TableName = strtoupper($tableName);
             $conn = db2_connect($database, $username, $password);
             $stmt = db2_primary_keys($conn, null, $schemaName, $db2TableName);
             $keys = db2_fetch_array($stmt);
             if (count($keys) > 3) {
                 $this->primary_key = $keys[3];
             } else {
                 throw new SCA_RuntimeException("Table '{$tableName}' does not appear to have a primary key.");
             }
         }
         $this->table_name = $this->_getName($tableName);
         if ($username != null) {
             $this->pdo = new PDO($this->config["dsn"], $username, $password, $this->config);
         } else {
             $this->pdo = new PDO($this->config["dsn"]);
         }
         $this->pdo_driver = $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
         $stmt = $this->pdo->prepare('SELECT * FROM ' . $this->table);
         if (!$stmt->execute()) {
             throw new SCA_RuntimeException(self::_getPDOError($stmt, "select"));
         }
         $columns = array();
         for ($i = 0; $i < $stmt->columnCount(); $i++) {
             $meta = $stmt->getColumnMeta($i);
             $name = $this->_getName($meta["name"]);
             if (in_array("primary_key", $meta["flags"], true)) {
                 $this->primary_key = $name;
             }
             $columns[] = $name;
         }
         //$pk = $this->_getName($this->primary_key);
         SCA::$logger->log("Table {$tableName} PrimaryKey {$this->primary_key}");
         /*
         $metadata = array(
         'name' => $this->table_name,
         'columns' => $columns,
         'PK' => $pk
         );
         */
         $this->datafactory = SDO_DAS_DataFactory::getDataFactory();
         // Define the model on the data factory (from the database)
         $this->datafactory->addType(SCA_Bindings_simpledb_Proxy::ROOT_NS, SCA_Bindings_simpledb_Proxy::ROOT_TYPE);
         $this->datafactory->addType($this->namespace, $this->table_name);
//.........这里部分代码省略.........
开发者ID:psagi,项目名称:sdo,代码行数:101,代码来源:Proxy.php

示例6: fetchRow

 /**
  * Fetch the next row from the given result object, in associative array
  * form. Fields are retrieved with $row['fieldname'].
  *
  * @param $res array|ResultWrapper SQL result object as returned from Database::query(), etc.
  * @return ResultWrapper row object
  * @throws DBUnexpectedError Thrown if the database returns an error
  */
 public function fetchRow($res)
 {
     if ($res instanceof ResultWrapper) {
         $res = $res->result;
     }
     if (db2_num_rows($res) > 0) {
         wfSuppressWarnings();
         $row = db2_fetch_array($res);
         wfRestoreWarnings();
         if ($this->lastErrno()) {
             throw new DBUnexpectedError($this, 'Error in fetchRow(): ' . htmlspecialchars($this->lastError()));
         }
         return $row;
     }
     return false;
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:24,代码来源:DatabaseIbm_db2.php

示例7: db2_connect

<?php

include 'config.php';
if (isset($_POST['username'])) {
    $conn = db2_connect($dbname, $username, $password);
    if ($conn) {
        $userName = $_POST['username'];
        $userNameQuery = "SELECT COUNT(*) FROM " . $computerName . ".USERS WHERE email = '{$userName}' ";
        $stmt = db2_prepare($conn, $userNameQuery);
        if ($stmt) {
            $result = db2_execute($stmt);
            if ($result) {
                $username_result = db2_fetch_array($stmt);
                if ($username_result[0] == '0') {
                    echo 'Username is available';
                } else {
                    echo 'Sorry, the Username ' . $userName . ' already exists!';
                }
            } else {
                db2_stmt_errormsg($stmt);
                db2_close($conn);
            }
        }
    }
}
开发者ID:TimmahC,项目名称:auctionsite,代码行数:25,代码来源:checkemail.php

示例8: dbi_fetch_row

/**
 * Retrieves a single row from the database and returns it as an array.
 *
 * <b>Note:</b> We don't use the more useful xxx_fetch_array because not all
 * databases support this function.
 *
 * <b>Note:</b> Use the {@link dbi_error()} function to get error information
 * if the connection fails.
 *
 * @param resource $res The database query resource returned from
 *                      the {@link dbi_query()} function.
 *
 * @return mixed An array of database columns representing a single row in
 *               the query result or false on an error.
 */
function dbi_fetch_row($res)
{
    if (strcmp($GLOBALS["db_type"], "mysql") == 0) {
        return mysql_fetch_array($res);
    } else {
        if (strcmp($GLOBALS["db_type"], "mysqli") == 0) {
            return mysqli_fetch_array($res);
        } else {
            if (strcmp($GLOBALS["db_type"], "mssql") == 0) {
                return mssql_fetch_array($res);
            } else {
                if (strcmp($GLOBALS["db_type"], "oracle") == 0) {
                    if (OCIFetchInto($GLOBALS["oracle_statement"], $row, OCI_NUM + OCI_RETURN_NULLS)) {
                        return $row;
                    }
                    return 0;
                } else {
                    if (strcmp($GLOBALS["db_type"], "postgresql") == 0) {
                        if (@$GLOBALS["postgresql_numrows[\"{$res}\"]"] > @$GLOBALS["postgresql_row[\"{$res}\"]"]) {
                            $r = pg_fetch_array($res, @$GLOBALS["postgresql_row[\"{$res}\"]"]);
                            @$GLOBALS["postgresql_row[\"{$res}\"]"]++;
                            if (!$r) {
                                echo "Unable to fetch row\n";
                                return '';
                            }
                        } else {
                            $r = '';
                        }
                        return $r;
                    } else {
                        if (strcmp($GLOBALS["db_type"], "odbc") == 0) {
                            if (!odbc_fetch_into($res, $ret)) {
                                return false;
                            }
                            return $ret;
                        } else {
                            if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) {
                                return db2_fetch_array($res);
                            } else {
                                if (strcmp($GLOBALS["db_type"], "ibase") == 0) {
                                    return ibase_fetch_row($res);
                                } else {
                                    dbi_fatal_error("dbi_fetch_row(): db_type not defined.");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
开发者ID:neymanna,项目名称:fusionforge,代码行数:67,代码来源:php-dbi.php

示例9: fetch_numarray

 /**	
  * Fetch a result row as a numeric array
  * @param Mixed qHanle		The query handle	 
  * @return Array
  */
 public function fetch_numarray($qHanle)
 {
     return db2_fetch_array($qHanle);
 }
开发者ID:ryanblanchard,项目名称:Dashboard,代码行数:9,代码来源:DB2Connection.php

示例10: fetch

 /**
  * {@inheritdoc}
  */
 public function fetch($fetchMode = null)
 {
     $fetchMode = $fetchMode ?: $this->_defaultFetchMode;
     switch ($fetchMode) {
         case \PDO::FETCH_BOTH:
             return db2_fetch_both($this->_stmt);
         case \PDO::FETCH_ASSOC:
             return db2_fetch_assoc($this->_stmt);
         case \PDO::FETCH_CLASS:
             $className = $this->defaultFetchClass;
             $ctorArgs = $this->defaultFetchClassCtorArgs;
             if (func_num_args() >= 2) {
                 $args = func_get_args();
                 $className = $args[1];
                 $ctorArgs = isset($args[2]) ? $args[2] : array();
             }
             $result = db2_fetch_object($this->_stmt);
             if ($result instanceof \stdClass) {
                 $result = $this->castObject($result, $className, $ctorArgs);
             }
             return $result;
         case \PDO::FETCH_NUM:
             return db2_fetch_array($this->_stmt);
         case \PDO::FETCH_OBJ:
             return db2_fetch_object($this->_stmt);
         default:
             throw new DB2Exception("Given Fetch-Style " . $fetchMode . " is not supported.");
     }
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:32,代码来源:DB2Statement.php

示例11: fetch

 /**
  * {@inheritdoc}
  */
 public function fetch($fetchMode = null)
 {
     $fetchMode = $fetchMode ?: $this->_defaultFetchMode;
     switch ($fetchMode) {
         case \PDO::FETCH_BOTH:
             return db2_fetch_both($this->_stmt);
         case \PDO::FETCH_ASSOC:
             return db2_fetch_assoc($this->_stmt);
         case \PDO::FETCH_NUM:
             return db2_fetch_array($this->_stmt);
         default:
             throw new DB2Exception("Given Fetch-Style " . $fetchMode . " is not supported.");
     }
 }
开发者ID:ashimidashajia,项目名称:zendstore,代码行数:17,代码来源:DB2Statement.php

示例12: fetch

 /**
  * fetch
  *
  * @see Query::HYDRATE_* constants
  * @param integer $fetchStyle           Controls how the next row will be returned to the caller.
  *                                      This value must be one of the Query::HYDRATE_* constants,
  *                                      defaulting to Query::HYDRATE_BOTH
  *
  * @param integer $cursorOrientation    For a PDOStatement object representing a scrollable cursor,
  *                                      this value determines which row will be returned to the caller.
  *                                      This value must be one of the Query::HYDRATE_ORI_* constants, defaulting to
  *                                      Query::HYDRATE_ORI_NEXT. To request a scrollable cursor for your
  *                                      PDOStatement object,
  *                                      you must set the PDO::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
  *                                      prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
  *
  * @param integer $cursorOffset         For a PDOStatement object representing a scrollable cursor for which the
  *                                      $cursorOrientation parameter is set to Query::HYDRATE_ORI_ABS, this value specifies
  *                                      the absolute number of the row in the result set that shall be fetched.
  *
  *                                      For a PDOStatement object representing a scrollable cursor for
  *                                      which the $cursorOrientation parameter is set to Query::HYDRATE_ORI_REL, this value
  *                                      specifies the row to fetch relative to the cursor position before
  *                                      PDOStatement->fetch() was called.
  *
  * @return mixed
  */
 function fetch($fetchStyle = \PDO::FETCH_BOTH)
 {
     switch ($fetchStyle) {
         case \PDO::FETCH_BOTH:
             return db2_fetch_both($this->_stmt);
         case \PDO::FETCH_ASSOC:
             return db2_fetch_assoc($this->_stmt);
         case \PDO::FETCH_NUM:
             return db2_fetch_array($this->_stmt);
         default:
             throw new DB2Exception("Given Fetch-Style " . $fetchStyle . " is not supported.");
     }
 }
开发者ID:manish436,项目名称:zform,代码行数:40,代码来源:DB2Statement.php

示例13: fetch

 /**
  * Fetches a row from the result set.
  *
  * @param int $style  OPTIONAL Fetch mode for this fetch operation.
  * @param int $cursor OPTIONAL Absolute, relative, or other.
  * @param int $offset OPTIONAL Number for absolute or relative cursors.
  * @return mixed Array, object, or scalar depending on fetch mode.
  * @throws \Zend\Db\Statement\Db2Exception
  */
 public function fetch($style = null, $cursor = null, $offset = null)
 {
     if (!$this->_stmt) {
         return false;
     }
     if ($style === null) {
         $style = $this->_fetchMode;
     }
     switch ($style) {
         case Db\Db::FETCH_NUM:
             $row = db2_fetch_array($this->_stmt);
             break;
         case Db\Db::FETCH_ASSOC:
             $row = db2_fetch_assoc($this->_stmt);
             break;
         case Db\Db::FETCH_BOTH:
             $row = db2_fetch_both($this->_stmt);
             break;
         case Db\Db::FETCH_OBJ:
             $row = db2_fetch_object($this->_stmt);
             break;
         case Db\Db::FETCH_BOUND:
             $row = db2_fetch_both($this->_stmt);
             if ($row !== false) {
                 return $this->_fetchBound($row);
             }
             break;
         default:
             throw new Db2Exception("Invalid fetch mode '{$style}' specified");
             break;
     }
     return $row;
 }
开发者ID:hjr3,项目名称:zf2,代码行数:42,代码来源:Db2.php

示例14: LCASE

			<?php 
//Connect to database
require_once "connect_db.php";
require_once "algorithm.php";
//Pull trait information from database
$songname = $_POST["name"];
$sql = "SELECT * FROM \"USER04893\" . \"Songs\" WHERE \"title\" = LCASE('" . $songname . "')";
$stmt = db2_exec($conn4, $sql);
$losongs;
$row;
//Fetches the list of similar songs
if (!$stmt) {
    echo "SQL Statement Failed" . db2_stmt_errormsg() . "";
    return;
} else {
    $row = db2_fetch_array($stmt);
    $top = getSongs($row);
    $losongs = $top;
}
?>
	<br>
	<center><img src="images/logo.png" height="300px" width="300px" /></center>
	<table>

		<tr>
			<td colspan="3">The song you searched for is: <?php 
echo ucwords($row[0]);
?>
 by <?php 
echo ucwords($row[1]);
?>
开发者ID:joshuasayavong,项目名称:watsong,代码行数:31,代码来源:get_artist.php

示例15: dbi_fetch_row

function dbi_fetch_row($res)
{
    if (strcmp($GLOBALS['db_type'], 'mysql') == 0) {
        return mysql_fetch_array($res, MYSQL_NUM);
    } elseif (strcmp($GLOBALS['db_type'], 'mysqli') == 0) {
        return $res->fetch_array(MYSQLI_NUM);
    } elseif (strcmp($GLOBALS['db_type'], 'mssql') == 0) {
        return mssql_fetch_array($res);
    } elseif (strcmp($GLOBALS['db_type'], 'oracle') == 0) {
        return OCIFetchInto($GLOBALS['oracle_statement'], $row, OCI_NUM + OCI_RETURN_NULLS) ? $row : 0;
    } elseif (strcmp($GLOBALS['db_type'], 'postgresql') == 0) {
        // Note: row became optional in PHP 4.1.0.
        $r = pg_fetch_array($res, null, PGSQL_NUM);
        return !$r ? false : $r;
    } elseif (strcmp($GLOBALS['db_type'], 'odbc') == 0) {
        return !odbc_fetch_into($res, $ret) ? false : $ret;
    } elseif (strcmp($GLOBALS['db_type'], 'ibm_db2') == 0) {
        return db2_fetch_array($res);
    } elseif (strcmp($GLOBALS['db_type'], 'ibase') == 0) {
        return ibase_fetch_row($res);
    } elseif (strcmp($GLOBALS['db_type'], 'sqlite') == 0) {
        return sqlite_fetch_array($res);
    } else {
        dbi_fatal_error('dbi_fetch_row (): ' . translate('db_type not defined.'));
    }
}
开发者ID:rhertzog,项目名称:lcs,代码行数:26,代码来源:dbi4php.php


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