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


PHP db2_fetch_object函数代码示例

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


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

示例1: query

function query($sql, $conn)
{
    try {
        $result = db2_exec($conn, $sql);
        $count = 0;
        while ($row = db2_fetch_object($result)) {
            echo $row->NAME1 . ", " . $row->NAME2 . " " . $row->STREET . ", " . $row->CITY . ", " . $row->STATE . ", " . $row->ZIP . ", " . $row->COUNTY . ", " . $row->LONG . ", " . $row->LAT . "<br>";
            $count++;
        }
        //print_r($result);
        if ($result) {
            echo "Query Successful<br>" . $count . " total entries<br>";
        }
    } catch (Exception $e) {
        echo "Query Failed<br>";
        echo "Exception: " . $e->getMessage() . "<br>";
        echo db2_conn_error() . "<br>";
        echo db2_conn_errormsg() . "<br>";
    }
}
开发者ID:emmendoza1986,项目名称:past_projects,代码行数:20,代码来源:db2test.php

示例2: 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_Db2_Exception
  */
 public function fetch($style = null, $cursor = null, $offset = null)
 {
     if (!$this->_stmt) {
         return false;
     }
     if ($style === null) {
         $style = $this->_fetchMode;
     }
     switch ($style) {
         case Zend_Db::FETCH_NUM:
             $row = db2_fetch_array($this->_stmt);
             break;
         case Zend_Db::FETCH_ASSOC:
             $row = db2_fetch_assoc($this->_stmt);
             break;
         case Zend_Db::FETCH_BOTH:
             $row = db2_fetch_both($this->_stmt);
             break;
         case Zend_Db::FETCH_OBJ:
             $row = db2_fetch_object($this->_stmt);
             break;
         case Zend_Db::FETCH_BOUND:
             $row = db2_fetch_both($this->_stmt);
             if ($row !== false) {
                 return $this->_fetchBound($row);
             }
             break;
         default:
             /**
              * @see Zend_Db_Statement_Db2_Exception
              */
             require_once PHP_LIBRARY_PATH . 'Zend/Db/Statement/Db2/Exception.php';
             throw new Zend_Db_Statement_Db2_Exception("Invalid fetch mode '{$style}' specified");
             break;
     }
     return $row;
 }
开发者ID:netixx,项目名称:Stock,代码行数:46,代码来源:Db2.php

示例3: 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

示例4: 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

示例5: fetchObject

 /**
  * Fetch the next row from the given result object, in object form.
  * Fields can be retrieved with $row->fieldname, with fields acting like
  * member variables.
  *
  * @param $res array|ResultWrapper SQL result object as returned from Database::query(), etc.
  * @return DB2 row object
  * @throws DBUnexpectedError Thrown if the database returns an error
  */
 public function fetchObject($res)
 {
     if ($res instanceof ResultWrapper) {
         $res = $res->result;
     }
     wfSuppressWarnings();
     $row = db2_fetch_object($res);
     wfRestoreWarnings();
     if ($this->lastErrno()) {
         throw new DBUnexpectedError($this, 'Error in fetchObject(): ' . htmlspecialchars($this->lastError()));
     }
     return $row;
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:22,代码来源:DatabaseIbm_db2.php

示例6: db2_exec

<?php

require 'php/connection.php';
$orderID = "";
$orderTime = "N/A";
$shippingType = "Unknown";
$shippingPrice = "Unknown";
$tax = "Unknown";
$products = "No products bought";
if (isset($_GET['orderID'])) {
    $query = "SELECT * FROM orderedItems join orderInfo on orderedItems.orderID = orderInfo.orderID WHERE orderID = " + orderID + ";";
    $results = db2_exec($_SESSION['connection'], $query);
    //only one entry
    while ($row = db2_fetch_object($results)) {
        $orderID = $row->orderID;
        $orderTime = $row->orderTime;
        $shippingType = $row->shippingType;
        $shippingPrice = $row->shippingPrice;
        $tax = $row->tax;
        $productID = $row->productID;
    }
}
开发者ID:allenbui94,项目名称:CS174_Ticon,代码行数:22,代码来源:orders.php

示例7: fetchObject

 /**
  * This function fetches a result row as an object.
  *
  * @param   mixed $result
  * @return  mixed
  * @access  public
  * @author  Thorsten Rinne <thorsten@phpmyfaq.de>
  * @author  Helmut Tessarek <tessus@evermeet.cx>
  * @since   2005-04-16
  */
 function fetchObject($result)
 {
     $_result = db2_fetch_object($result);
     if (is_object($_result)) {
         return (object) array_change_key_case(get_object_vars($_result), CASE_LOWER);
     } else {
         return false;
     }
 }
开发者ID:nosch,项目名称:phpMyFAQ,代码行数:19,代码来源:Ibm_db2.php

示例8: fetch_object

 public static function fetch_object($psql, $fetchall, $conn = null)
 {
     if ($psql) {
         if (!$fetchall) {
             return db2_fetch_object($psql);
         } else {
             $ret = array();
             while ($obj = db2_fetch_object($psql)) {
                 $ret[] = $obj;
             }
             return $ret;
         }
     }
     return false;
 }
开发者ID:Russell-IO,项目名称:php-syslog-ng,代码行数:15,代码来源:jqGridDb2.php

示例9: fetchObject

 /**
  * Fetch the next row from the given result object, in object form.
  * Fields can be retrieved with $row->fieldname, with fields acting like
  * member variables.
  *
  * @param $res SQL result object as returned from Database::query(), etc.
  * @return DB2 row object
  * @throws DBUnexpectedError Thrown if the database returns an error
  */
 public function fetchObject($res)
 {
     if ($res instanceof ResultWrapper) {
         $res = $res->result;
     }
     @($row = db2_fetch_object($res));
     if ($this->lastErrno()) {
         throw new DBUnexpectedError($this, 'Error in fetchObject(): ' . htmlspecialchars($this->lastError()));
     }
     // Make field names lowercase for compatibility with MySQL
     if ($row) {
         $row2 = new BlankObject();
         foreach ($row as $key => $value) {
             $keyu = strtolower($key);
             $row2->{$keyu} = $value;
         }
         $row = $row2;
     }
     return $row;
 }
开发者ID:josephdye,项目名称:wikireader,代码行数:29,代码来源:DatabaseIbm_db2.php


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