本文整理汇总了PHP中sqlsrv_get_field函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlsrv_get_field函数的具体用法?PHP sqlsrv_get_field怎么用?PHP sqlsrv_get_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlsrv_get_field函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cs_sql_count
function cs_sql_count($cs_file, $sql_table, $sql_where = 0, $distinct = 0)
{
global $cs_db;
$row = empty($distinct) ? '*' : 'DISTINCT ' . $distinct;
$sql_query = 'SELECT COUNT(' . $row . ') FROM ' . $cs_db['prefix'] . '_' . $sql_table;
$sql_query .= empty($sql_where) ? '' : ' WHERE ' . $sql_where;
$sql_query = str_replace('{pre}', $cs_db['prefix'], $sql_query);
if (!($sql_data = sqlsrv_query($cs_db['con'], $sql_query))) {
cs_error_sql($cs_file, 'cs_sql_count', cs_sql_error(0, $sql_query));
return NULL;
}
sqlsrv_fetch($sql_data);
$sql_result = sqlsrv_get_field($sql_data, 0);
sqlsrv_free_stmt($sql_data);
cs_log_sql($cs_file, $sql_query);
return $sql_result;
}
示例2: query
public static function query($queryStr = '', $objectStr = '')
{
$queryDB = sqlsrv_query(self::$dbConnect, $queryStr);
if (preg_match('/insert into/i', $queryDB)) {
sqlsrv_next_result($queryDB);
sqlsrv_fetch($queryDB);
self::$insertID = sqlsrv_get_field($queryDB, 0);
}
if ($queryDB) {
if (is_object($objectStr)) {
$objectStr($queryDB);
}
// sqlsrv_free_stmt($queryDB);
return $queryDB;
} else {
self::$error = sqlsrv_errors();
return false;
}
}
示例3: get_topic_id
function get_topic_id($topic)
{
$params = array($topic);
$options = array("Scrollable" => 'static');
$addTopicSQL = "INSERT into Topics Values (?)";
$getTopicIDSQL = "SELECT TOP 1 TopicID FROM Topics \n WHERE Topic = ?\n ORDER BY TopicID Desc";
$TopicID = 0;
$addTopic = sqlsrv_query($con, $addTopicSQL, $params, $options);
if ($addTopic === false) {
die(print_r(sqlsrv_errors(), true));
}
$getTopicID = sqlsrv_query($con, $getTopicIDSQL, $params, $options);
if ($getTopicID === false) {
die(print_r(sqlsrv_errors(), true));
}
if (sqlsrv_fetch($getTopicID) === true) {
$TopicID = sqlsrv_get_field($getTopicID, 0);
}
return $TopicID;
}
示例4: fetchColumn
/**
* Returns a single column from the next row of a result set.
*
* @param int $col OPTIONAL Position of the column to fetch.
* @return string
* @throws \Zend\DB\Statement\Exception
*/
public function fetchColumn($col = 0)
{
if (!$this->_stmt) {
return false;
}
if (!sqlsrv_fetch($this->_stmt)) {
if (null !== ($error = sqlsrv_errors())) {
throw new Exception($error);
}
// If no error, there is simply no record
return false;
}
$data = sqlsrv_get_field($this->_stmt, $col);
//0-based
if ($data === false) {
throw new Exception(sqlsrv_errors());
}
return $data;
}
示例5: die
die(print_r(sqlsrv_errors(), true));
}
$num_admins = sqlsrv_num_rows($admins);
$institutions = [];
$fnames = [];
$lnames = [];
$adminids = [];
$designations = [];
$dates = [];
while (sqlsrv_fetch($admins) === true) {
$institutions[] = sqlsrv_get_field($admins, 0);
$fnames[] = sqlsrv_get_field($admins, 1);
$lnames[] = sqlsrv_get_field($admins, 2);
$adminids[] = sqlsrv_get_field($admins, 3);
$designations[] = sqlsrv_get_field($admins, 4);
$dates[] = sqlsrv_get_field($admins, 5);
}
?>
<body>
<div id="wrapper">
<div id="sidebar"></div>
<div id="page-content-wrapper">
<button type="button" class="hamburger is-closed" data-toggle="offcanvas">
<span class="hamb-top"></span>
<span class="hamb-middle"></span>
<span class="hamb-bottom"></span>
</button>
<div class="container-fluid">
<div class="row">
<div class="col-lg-8">
<h1>Smalltalk Admins</h1>
示例6: _query
function _query($sql, $inputarr = false)
{
$this->_errorMsg = false;
if (is_array($sql)) {
$sql = $sql[1];
}
$insert = false;
// handle native driver flaw for retrieving the last insert ID
if (preg_match('/^\\W*insert\\s(?:(?:(?:\'\')*\'[^\']+\'(?:\'\')*)|[^;\'])*;?$/i', $sql)) {
$insert = true;
$sql .= '; ' . $this->identitySQL;
// select scope_identity()
}
if ($inputarr) {
$rez = sqlsrv_query($this->_connectionID, $sql, $inputarr);
} else {
$rez = sqlsrv_query($this->_connectionID, $sql);
}
if ($this->debug) {
ADOConnection::outp("<hr>running query: " . var_export($sql, true) . "<hr>input array: " . var_export($inputarr, true) . "<hr>result: " . var_export($rez, true));
}
if (!$rez) {
$rez = false;
} else {
if ($insert) {
// retrieve the last insert ID (where applicable)
while (sqlsrv_next_result($rez)) {
sqlsrv_fetch($rez);
$this->lastInsertID = sqlsrv_get_field($rez, 0);
}
}
}
return $rez;
}
示例7: insert_id
protected function insert_id($db, $result)
{
sqlsrv_next_result($result);
sqlsrv_fetch($result);
return (int) sqlsrv_get_field($result, 0);
}
示例8: _fetch
/**
* @brief 결과를 fetch
**/
function _fetch($result)
{
if (!$this->isConnected() || $this->isError() || !$result) {
return;
}
$c = sqlsrv_num_fields($result);
$m = null;
$output = array();
while (sqlsrv_fetch($result)) {
if (!$m) {
$m = sqlsrv_field_metadata($result);
}
unset($row);
for ($i = 0; $i < $c; $i++) {
$row->{$m[$i]['Name']} = sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING('utf-8'));
}
$output[] = $row;
}
if (count($output) == 1) {
return $output[0];
}
return $output;
}
示例9: array
$pwd = "123456";
$connectionInfo = array("UID" => $uid, "PWD" => $pwd, "Database" => "MBOOK");
$conn = sqlsrv_connect($serverName, $connectionInfo);
sqlsrv_query($conn, "set names GB2312");
$sql = "SELECT * FROM TBook WHERE TBook.ISBN='{$isbn}'";
$result = sqlsrv_query($conn, $sql);
$row = sqlsrv_fetch($result);
$book_name = sqlsrv_get_field($result, 1);
$author = sqlsrv_get_field($result, 2);
$publisher = sqlsrv_get_field($result, 3);
$publish_date = sqlsrv_get_field($result, 4, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
$price = sqlsrv_get_field($result, 5);
$fuben_num = sqlsrv_get_field($result, 6);
$store_num = sqlsrv_get_field($result, 7);
$type_num = sqlsrv_get_field($result, 8);
$content_view = sqlsrv_get_field($result, 9);
$sql = "SELECT * FROM TBLend WHERE ISBN='{$isbn}' AND 是否借出=0";
$result = sqlsrv_query($conn, $sql);
require_once "top_menu.php";
?>
<!--内容模块-->
<div class="container">
<div class="content_display_book">
<table class="table table-bordered">
<thead>
<th colspan="3"><p class="text-center">图书信息表</p></th>
</thead>
<tbody>
<tr>
<td><strong>ISBN</strong></td>
<td><?php
示例10: sqlsrv_query
<?php
include 'DBConnection.php';
$lng_min = $_REQUEST['lng_min'];
$lat_min = $_REQUEST['lat_min'];
$lng_max = $_REQUEST['lng_max'];
$lat_max = $_REQUEST['lat_max'];
$tsql = "SELECT event_id, latitude, longtitude, name, working_on, looking_for FROM event WHERE longtitude >= {$lng_min} AND longtitude <= {$lng_max} AND latitude >= {$lat_min} AND latitude <= {$lat_max}";
$stmt = sqlsrv_query($conn, $tsql);
if ($stmt === false) {
echo "Error in statement preparation/execution.\n";
die(print_r(sqlsrv_errors(), true));
}
echo '[';
$is_first = 1;
while (sqlsrv_fetch($stmt)) {
$event_id = sqlsrv_get_field($stmt, 0);
$lat = sqlsrv_get_field($stmt, 1);
$lng = sqlsrv_get_field($stmt, 2);
$name = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
$working_on = sqlsrv_get_field($stmt, 4, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
$looking_for = sqlsrv_get_field($stmt, 5, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
if ($is_first == 0) {
echo ",";
}
echo "[\"{$event_id}\", \"{$lat}\",\"{$lng}\",\"{$name}\", \"{$working_on}\", \"{$looking_for}\"]";
$is_first = 0;
}
echo ']';
include 'DBConnectionClose.php';
示例11: insert_records
public function insert_records($tablename, $datas)
{
//Before any Query, first get the table description
if (!$this->describe_table($tablename)) {
return false;
}
if (!(gettype($datas) == 'array')) {
trigger_error("Unsupported datatype for datas. Array expected, " . gettype($datas) . " passed", E_USER_ERROR);
return false;
}
if (sizeof($datas) < 1) {
trigger_error("No values passed to insert query", E_USER_ERROR);
return false;
}
$sql = "INSERT INTO " . $tablename . " ";
//$tempdata = array_values($datas);
$insertclause = $this->insert_clause_builder($datas[0]);
$placeholder = array();
$i = sizeof($datas);
while ($i > 0) {
$placeholder[] = $insertclause[1];
$i--;
}
$insertclause[1] = implode(",", $placeholder);
$sql .= $insertclause[0] . " VALUES " . $insertclause[1] . "; SELECT SCOPE_IDENTITY();";
$tempArray = array();
foreach ($data as $key => $value) {
$tempArray[] =& $value;
}
$stmt = sqlsrv_query($this->connection, $sql, $tempArray);
if (!$stmt) {
return false;
}
sqlsrv_next_result($stmt);
sqlsrv_fetch($stmt);
$newId = sqlsrv_get_field($stmt, 0);
if ($newId > 0) {
return $newId;
} else {
return true;
}
}
示例12: user_is_role
function user_is_role($email, $role)
{
$return_value = 0;
$user_id = user_exist_sqlsrv($email);
$role_id = role_to_roleid($role);
global $conn;
$qry = "SELECT count(*) AS count FROM user_role WHERE user_id = ? AND role_id = ? AND active = 1";
$params = array(&$user_id, &$role_id);
$rst = sqlsrv_prepare($conn, $qry, $params);
sqlsrv_execute($rst);
sqlsrv_fetch($rst);
error_log("checked {$email} for role {$role} using {$user_id} and {$role_id}");
$return_value = sqlsrv_get_field($rst, 0);
sql_errors_display("from user is role");
return $return_value;
}
示例13: nextID
/**
* Returns the next ID of a table
*
* @param string $table the name of the table
* @param string $id the name of the ID column
* @return int
*/
public function nextID($table, $id)
{
$select = sprintf("\n SELECT \n max(%d) as current_id \n FROM \n %s", $id, $table);
$result = $this->query($select);
$stmt = sqlsrv_fetch($result);
return sqlsrv_get_field($stmt, 0) + 1;
}
示例14: die
if ($conn) {
echo "Connection established.<br />";
} else {
echo "Connection could not be established.<br />";
die(print_r(sqlsrv_errors(), true));
}
$sql = "SELECT MasterPatientID FROM vCrgvrPrtl_User\tWHERE vCrgvrPrtl_User.CaregiverPin = '{$pin}' AND UPPER(vCrgvrPrtl_User.FirstName) = '{$firstname}' AND UPPER(vCrgvrPrtl_User.LastName) ='{$lastname}';";
$stmt = sqlsrv_query($conn, $sql);
if ($stmt === false) {
die(print_r(sqlsrv_errors(), true));
} else {
if (sqlsrv_has_rows($stmt) != 1) {
header("location: logerror.php");
// Redirecting To Invalid pin Page
} else {
// Make the first (and in this case, only) row of the result set available for reading.
if (sqlsrv_fetch($stmt) === false) {
die(print_r(sqlsrv_errors(), true));
} else {
// Get the row fields. Field indeces start at 0 and must be retrieved in order.
// Retrieving row fields by name is not supported by sqlsrv_get_field.
$mpi = sqlsrv_get_field($stmt, 0);
$_SESSION['mpi'] = $mpi;
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);
header("location: portal.php");
// Redirecting To Other Page
}
}
}
}
示例15: fetchColumn
/**
* Returns a single column from the next row of a
* result set or FALSE if there are no more rows.
*
* @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
* value is supplied, Doctrine_Adapter_Statement_Interface->fetchColumn()
* fetches the first column.
*
* @return string returns a single column in the next row of a result set.
*/
public function fetchColumn($columnIndex = 0)
{
if (!is_integer($columnIndex)) {
$this->handleError(array('message' => "columnIndex parameter should be numeric"));
}
if (!$this->statement) {
return false;
}
if (false === sqlsrv_fetch($this->statement)) {
if (null !== ($error = sqlsrv_errors())) {
$this->handleError();
}
// If no error, there is simply no record
return false;
}
$data = sqlsrv_get_field($this->statement, $columnIndex);
//0-based
if ($data === false) {
$this->handleError();
}
return $data;
}