本文整理汇总了PHP中sqlsrv_num_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlsrv_num_fields函数的具体用法?PHP sqlsrv_num_fields怎么用?PHP sqlsrv_num_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlsrv_num_fields函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: result_mssqlnative
public function result_mssqlnative($queryresult = false)
{
$this->m_cursor = 0;
$this->m_rows = array();
$this->m_num_fields = sqlsrv_num_fields($queryresult);
$this->m_field_meta = sqlsrv_field_metadata($queryresult);
while ($row = sqlsrv_fetch_array($queryresult, SQLSRV_FETCH_ASSOC)) {
if ($row !== null) {
foreach ($row as $k => $v) {
if (is_object($v) && method_exists($v, 'format')) {
$row[$k] = $v->format("Y-m-d\\TH:i:s\\Z");
}
}
$this->m_rows[] = $row;
//read results into memory, cursors are not supported
}
}
$this->m_row_count = sizeof($this->m_rows);
}
示例2: _post_query
function _post_query($dbh, $query)
{
++$this->num_queries;
if (defined('SAVEQUERIES') && SAVEQUERIES) {
$this->queries[] = array($query, $this->timer_stop(), $this->get_caller());
}
// If there is an error then take note of it..
if ($this->result == FALSE) {
$this->last_error = sqlsrv_errors(SQLSRV_ERR_ALL);
if ($this->last_error != '') {
$this->log_query($this->last_error);
//echo "<pre>";
//var_dump($query);
//var_dump($this->translation_changes);
//echo "</pre>";
$this->print_error();
}
return false;
}
if (preg_match("/^\\s*(insert|delete|update|replace) /i", $query)) {
$this->rows_affected = sqlsrv_rows_affected($this->result);
// Take note of the insert_id
if (preg_match("/^\\s*(insert|replace) /i", $query)) {
$result = @sqlsrv_fetch_object(@sqlsrv_query($dbh, "SELECT SCOPE_IDENTITY() AS ID"));
$this->insert_id = $result->ID;
}
$return_val = $this->rows_affected;
} else {
$i = 0;
while ($i < @sqlsrv_num_fields($this->result)) {
$field = @sqlsrv_field_metadata($this->result);
if ($field[0]['Type'] == -1) {
$type = 'text';
} elseif ($field[0]['Type'] == 12) {
$type = 'char';
} elseif ($field[0]['Type'] == -5) {
$type = 'numeric';
} else {
$type = $field[0]['Type'];
}
$new_field = new stdClass();
$new_field->name = $field[0]['Name'];
$new_field->table = $field[0]['Name'];
$new_field->def = null;
$new_field->max_length = $field[0]['Size'];
$new_field->not_null = true;
$new_field->primary_key = null;
$new_field->unique_key = null;
$new_field->multiple_key = null;
$new_field->numeric = $field[0]['Precision'];
$new_field->blob = null;
$new_field->type = $type;
$new_field->unsigned = null;
$new_field->zerofill = null;
$this->col_info[$i] = $new_field;
$i++;
}
$num_rows = 0;
while ($row = @sqlsrv_fetch_object($this->result)) {
$this->last_result[$num_rows] = $row;
$num_rows++;
}
$this->last_result = $this->fix_results($this->last_result);
// perform limit
if (!empty($this->limit)) {
$this->last_result = array_slice($this->last_result, $this->limit['from'], $this->limit['to']);
$num_rows = count($this->last_result);
}
@sqlsrv_free_stmt($this->result);
// Log number of rows the query returned
$this->num_rows = $num_rows;
// Return number of rows selected
$return_val = $this->num_rows;
}
$this->log_query();
return $return_val;
}
示例3: num_fields
/**
* Number of fields in the result set
*
* @return int
*/
public function num_fields()
{
return @sqlsrv_num_fields($this->result_id);
}
示例4: columnCount
public function columnCount()
{
return sqlsrv_num_fields($this->stmt);
}
示例5: sql_num_fields
function sql_num_fields($sqltype, $result)
{
if ($sqltype == 'mysql') {
if (class_exists('mysqli_result')) {
return $result->field_count;
} elseif (function_exists('mysql_num_fields')) {
return mysql_num_fields($result);
}
} elseif ($sqltype == 'mssql') {
if (function_exists('sqlsrv_num_fields')) {
return sqlsrv_num_fields($result);
} elseif (function_exists('mssql_num_fields')) {
return mssql_num_fields($result);
}
} elseif ($sqltype == 'pgsql') {
return pg_num_fields($result);
} elseif ($sqltype == 'oracle') {
return oci_num_fields($result);
} elseif ($sqltype == 'sqlite3') {
return $result->numColumns();
} elseif ($sqltype == 'sqlite') {
return sqlite_num_fields($result);
} elseif ($sqltype == 'odbc') {
return odbc_num_fields($result);
} elseif ($sqltype == 'pdo') {
return $result->columnCount();
}
}
示例6: _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;
}
示例7: numFields
/**
* @param mixed $res
* @return int
*/
public function numFields($res)
{
if ($res instanceof ResultWrapper) {
$res = $res->result;
}
return sqlsrv_num_fields($res);
}
示例8: __construct
public function __construct($queryresult = false)
{
$this->mCursor = 0;
$this->mRows = array();
$this->mNumFields = sqlsrv_num_fields($queryresult);
$this->mFieldMeta = sqlsrv_field_metadata($queryresult);
$rows = sqlsrv_fetch_array($queryresult, SQLSRV_FETCH_ASSOC);
foreach ($rows as $row) {
if ($row !== null) {
foreach ($row as $k => $v) {
if (is_object($v) && method_exists($v, 'format')) {
// DateTime Object
$row[$k] = $v->format("Y-m-d\\TH:i:s\\Z");
}
}
$this->mRows[] = $row;
// read results into memory, cursors are not supported
}
}
$this->mRowCount = count($this->mRows);
sqlsrv_free_stmt($queryresult);
}
示例9: sqlsrv_query
}
echo "Connected!\n";
$s = sqlsrv_query($c, 'drop table [php_table_1_WREADHYPERV]');
$s = sqlsrv_query($c, 'create table [php_table_1_WREADHYPERV] ([γεια σας κόσμο] [nvarchar](100) NOT NULL,
[col2] [nvarchar](100) NOT NULL,
[col3] [nvarchar](100) NOT NULL)');
if ($s === false) {
die(print_r(sqlsrv_errors(), true));
}
$stmt = sqlsrv_query($c, 'SELECT * FROM [php_table_1_WREADHYPERV]');
if ($stmt === false) {
die(print_r(sqlsrv_errors(), true));
}
$ct = 1;
do {
if (sqlsrv_num_fields($stmt) > 0) {
$meta = sqlsrv_field_metadata($stmt);
foreach ($meta as &$col) {
$col['BinaryName'] = '0x' . bin2hex($col['Name']);
}
echo "Result {$ct} Meta Data:\r\n" . print_r($meta, true);
$ctr = 0;
while ($row = sqlsrv_fetch_array($stmt)) {
++$ctr;
echo "Result {$ct} Row {$ctr}:" . print_r($row, true);
}
} else {
echo 'Result ' . $ct . " has no result set.\r\n";
}
++$ct;
} while ($rv = sqlsrv_next_result($stmt));
示例10: die
}
}
} else {
echo "Connection could not be established.<br />";
die(print_r(sqlsrv_errors(), true));
}
}
if ($strTrigger == "PopulateInboxTable") {
if ($conn) {
$check = "DECLARE @return_value int EXEC @return_value = [proirb]. [CIRB_spQQQProtocol] @CustNum='101', @TaskList_AssignToLogonName='{$strLogonName}', @TaskList_Complete='0', @SpecialSProc=Protocols4TaskList";
$result = sqlsrv_query($conn, $check);
if (!($info = sqlsrv_fetch_array($result))) {
echo 'sql statement bad';
} else {
//build table
$fcount = sqlsrv_num_fields($result);
$tag = sqlsrv_field_metadata($result);
$Num = 0;
while ($row = sqlsrv_fetch_array($result)) {
//echo json_encode ($row);
$Num++;
print "<div id='" . $Num . "' class='card' ng-click=CardClick()>";
print "<p id='inboxTitle'>" . $row['Title'] . "</td>";
print "<p id='inboxTask'>" . $row['TaskVerbage'] . "</td>";
print "<p id='inboxProtNum'>" . $row['ProtocolNum'] . "</td>";
print "<p id='inboxType'>" . $row['Type'] . "</td>";
//print("<td data-title='ID'>".$row['PI4Protocol']."</td>");
//print("<td data-title='ID' id='".$Num."TaskID' style='display:none;'>".$row['TaskID']."</td>");
// print("<td data-title='ID' id='".$Num."RefNum' style='display:none;'>".$row['RefNum']."</td>");
print "</div>";
}
示例11: num_fields
/**
* Get number of fields in a result
* @param Mixed qHanle The query handle
* @return Number
*/
public function num_fields($qHandle)
{
return @sqlsrv_num_fields($qHandle);
}
示例12: BaseDB
</div>
<br>
<?php
$dbBaseClass = new BaseDB();
if (Database::getConnection() === false) {
$_SESSION['error'] = "ERROR: Could not connect. " . printf('%s', dbGetErrorMsg());
header("Location: Default.php");
exit;
}
$records = $dbBaseClass->getFieldsByFilter('Branch', array('id', 'BranchCode', 'Name', 'PhoneNumber', 'ContactPersonName', 'ContactPersonNumber', 'FaxNumber', 'ContactPersonEmail', 'BusinessEntityId'), $filter);
if ($records === false) {
$_SESSION['error'] = dbGetErrorMsg();
header("Location: Default.php");
exit;
}
$numFields = sqlsrv_num_fields($records);
echo "<table class='withBorder'>";
echo "<thead>";
echo "<tr><th>Branch</th><th>Name</th><th>Phone Number</th><th>ContactPersonName</th><th>ContactPersonNumber</th><th>FaxNumber</th><th>ContactPersonEmail</th><th colspan=\"3\">Actions</th></tr>";
echo '</thead>';
while ($record = sqlsrv_fetch_array($records, SQLSRV_FETCH_BOTH)) {
echo "<tr>";
echo "<td>{$record['BranchCode']}</td>";
echo "<td>{$record['Name']}</td>";
echo "<td>{$record['PhoneNumber']}</td>";
echo "<td>{$record['ContactPersonName']}</td>";
echo "<td>{$record['ContactPersonNumber']}</td>";
echo "<td>{$record['FaxNumber']}</td>";
echo "<td>{$record['ContactPersonEmail']}</td>";
echo "<td><a href=Branch.php?action=r&id={$record['id']}&entityId={$record['BusinessEntityId']}><img src=\"images/icons/view.png\" /></a></td>";
echo "<td><a href=Branch.php?action=u&id={$record['id']}&entityId={$record['BusinessEntityId']}><img src=\"images/icons/edit.png\" /></a></td>";
示例13: set_num_fields
public function set_num_fields()
{
$this->num_fields = sqlsrv_num_fields($this->resource);
}
示例14: get_num_of_columns
/**
* Возвращает количетсво колонок
*
* @return int
*/
public function get_num_of_columns()
{
return sqlsrv_num_fields($this->stmt);
}
示例15: _fetchRowAssoc
/**
* Low level handling getting a row from a result set; automatically
* makes all fetched values strings, just like the other PHP db functions.
* We have to do this since the sqlsrv extension returns row values in thier
* native types, which causes problems with how we handle things.
*
* @param resource $result
* @return array
*/
private function _fetchRowAssoc($result)
{
if (!is_resource($result)) {
return false;
}
$row = array();
$fieldnames = $this->getFieldsArray($result);
$fieldMetaData = sqlsrv_field_metadata($result);
if (sqlsrv_fetch($result)) {
for ($i = 0; $i < sqlsrv_num_fields($result); $i++) {
if ($fieldMetaData[$i]['Type'] == -9 || $fieldMetaData[$i]['Type'] >= SQLSRV_SQLTYPE_NVARCHAR(1) && $fieldMetaData[$i]['Type'] <= SQLSRV_SQLTYPE_NVARCHAR(8000) || $fieldMetaData[$i]['Type'] >= SQLSRV_SQLTYPE_NCHAR(1) && $fieldMetaData[$i]['Type'] <= SQLSRV_SQLTYPE_NCHAR(8000) || $fieldMetaData[$i]['Type'] == SQLSRV_SQLTYPE_NVARCHAR('max') || $fieldMetaData[$i]['Type'] == SQLSRV_SQLTYPE_NCHAR('max')) {
$row[$fieldnames[$i]] = iconv("utf-16le", "utf-8", sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_BINARY)));
} else {
$row[$fieldnames[$i]] = sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
}
}
} else {
sqlsrv_free_stmt($result);
}
return $row;
}