本文整理汇总了PHP中db2_fetch_both函数的典型用法代码示例。如果您正苦于以下问题:PHP db2_fetch_both函数的具体用法?PHP db2_fetch_both怎么用?PHP db2_fetch_both使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db2_fetch_both函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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.");
}
}
示例3: 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.");
}
}
示例4: 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;
}
示例5: 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.");
}
}
示例6: 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;
}
示例7: reportFlowPressureByDM
/**
*
* @apiName ReportFlowPressureByDM
* @apiGroup Report Manager
* @apiVersion 0.1.0
*
* @api {post} /reportManager/reportFlowPressureByDM/ reportFlowPressureByDM
* @apiDescription คำอธิบาย : ในส่วนนี้ทำหน้าที่แสดงรายการ RTU พร้อมค่า Flow, Pressure แยกแต่ละ DM
*
*/
function reportFlowPressureByDM($app, $pdo, $db, $conn_db2, $key)
{
$myBranchCode = "";
/* ************************* */
/* เริ่มกระบวนการ Extract the jwt from the Header or Session */
/* ************************* */
if (!isset($_SESSION['jwt'])) {
// $jwt = "";
/*** Extract the jwt from the Bearer ***/
$request = $app->request();
$authHeader = $request->headers('authorization');
list($jwt) = sscanf((string) $authHeader, 'Bearer %s');
$myBranchCode = $app->jwt->information->branchCode;
} else {
/*** Extract the jwt from Session ***/
$jwt = $_SESSION['jwt'];
$token = JWT::decode($jwt, $key, array('HS256'));
$myBranchCode = $token->information->branchCode;
}
/* ************************* */
/* เริ่มกระบวนการเชื่อมต่อฐานข้อมูล MySQL */
/* ************************* */
$reports = array();
if ($myBranchCode != "ALL") {
$results = $db->rtu_main_tb->where("branch_code = ? and rtu_status = 1", $myBranchCode)->order("dm_code ASC");
} else {
$results = $db->rtu_main_tb->where("rtu_status = 1")->order("dm_code ASC");
}
/* ************************* */
/* เริ่มกระบวนการเชื่อมต่อฐานข้อมูล DB2 ของ WLMA */
/* ************************* */
foreach ($results as $result) {
$result_rtu_pin_code = $db->rtu_pin_code_tb->where("dm_code = ? and enable = 1", $result["dm_code"])->fetch();
$sql_flow = "SELECT * from METER_ONLINE_DATA_LAST WHERE METER_CODE = '" . $result["dm_code"] . "' and LOG_TYPE = 'F'";
$sql_pressure = "SELECT * from METER_ONLINE_DATA_LAST WHERE METER_CODE = '" . $result["dm_code"] . "' and LOG_TYPE = 'P'";
if ($conn_db2) {
$stmt_flow = db2_exec($conn_db2, $sql_flow);
$stmt_pressure = db2_exec($conn_db2, $sql_pressure);
}
$row_flow = db2_fetch_both($stmt_flow);
$row_pressure = db2_fetch_both($stmt_pressure);
$tmpFlowValue = iconv("TIS-620//IGNORE", "UTF-8//IGNORE", $row_flow["VALUE"]);
$tmpFlowTimestamp = iconv("TIS-620//IGNORE", "UTF-8//IGNORE", $row_flow["RTU_LOG_DT"]);
$tmpPressureValue = iconv("TIS-620//IGNORE", "UTF-8//IGNORE", $row_pressure["VALUE"]);
$tmpPressureTimestamp = iconv("TIS-620//IGNORE", "UTF-8//IGNORE", $row_pressure["RTU_LOG_DT"]);
$reports[] = array("id" => $result["id"], "dm" => $result["dm_code"], "dma" => $result["dma_code"], "branch" => $result["branch_code"], "zone" => $result["zone_code"], "ip_address" => $result["ip_address"], "logger_code" => $result["logger_code"], "comm_type" => $result["comm_type"], "status" => $result["rtu_status"], "remark" => $result["remark"], "rtu_pin_code" => $result_rtu_pin_code["rtu_pin_code"], "lat" => $result_rtu_pin_code["lat"], "lng" => $result_rtu_pin_code["lng"], "location" => $result_rtu_pin_code["location"], "flow_value" => $tmpFlowValue, "flow_timestamp" => $tmpFlowTimestamp, "pressure_value" => $tmpPressureValue, "pressure_timestamp" => $tmpPressureTimestamp);
}
$rowCount = count($results);
/* ************************* */
/* เริ่มกระบวนการส่งค่ากลับ */
/* ************************* */
$resultText = "success";
$reportResult = array("result" => $resultText, "count" => $rowCount, "rows" => $reports);
$app->response()->header("Content-Type", "application/json");
echo json_encode($reportResult);
}
示例8: 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);
}