本文整理汇总了PHP中mysqli_field_count函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_field_count函数的具体用法?PHP mysqli_field_count怎么用?PHP mysqli_field_count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_field_count函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ExportTable
function ExportTable($conn, $title, $filter, $dbtable, $dbjoin = "", $joinfield = "")
{
$query = "SELECT * FROM {$dbtable}";
if ($dbjoin) {
$query .= " INNER JOIN {$dbjoin} ON {$dbtable}.{$joinfield}={$dbjoin}.{$joinfield}";
}
if ($filter) {
$query .= " WHERE {$filter}";
}
$result = mysqli_query($conn, $query);
$nrcampos = mysqli_field_count($conn);
echo "<h2>{$title}</h2>";
echo "{$dbtable}";
if ($dbjoin) {
echo "| <a href=\"dbshow.php?dbtable={$dbjoin}\" target=\"_blank\">{$dbjoin}</a>";
}
echo "| " . mysqli_num_rows($result) . " row(s)";
echo "<p><table cellspacing=\"0\" cellpadding=\"5\" border=\"1\">";
echo "<tr>";
for ($i = 0; $i < $nrcampos; $i++) {
$finfo = mysqli_fetch_field_direct($result, $i);
echo "<td>" . $finfo->name . "</td>";
}
echo "</tr>";
while ($row = mysqli_fetch_array($result)) {
echo "<tr>";
for ($i = 0; $i < $nrcampos; $i++) {
echo "<td>" . $row[$i] . "</td>";
}
echo "</tr>";
}
echo "</table></p><br> ";
}
示例2: fnGetEventData
function fnGetEventData($intThresholdEventID, $intColIndex)
{
#$intSensorID = fnGet
#if (!Is_Null($intSensorID)) {
#$fnGEDSQL = "SELECT * FROM `tblthresholdevents` WHERE ((intThresholdEventID=" . $intThresholdEventID . ") AND booInProcess=1) OR ((intThresholdEventID=" . $intThresholdEventID . ") AND booIsNew=1)";
$fnGEDSQL = "SELECT * FROM `tblthresholdevents` WHERE ((intThresholdEventID=" . $intThresholdEventID . "))";
# AND booInProcess=1) OR ((intSensorID=" . $intSensorID . ") AND booIsNew=1)";
echo "<br>!?!?!? fnGEDSQL: " . $fnGEDSQL;
$linkged = mysqli_connect('localhost', 'root', '', 'climatecontroldata');
$EventData = mysqli_query($linkged, $fnGEDSQL);
#$rsEventData = mysqli_fetch_assoc($EventData);
$intResCount = @mysqli_num_rows($EventData);
$intCols = mysqli_field_count($linkged);
if ($intColIndex <= $intCols) {
# echo "<br>Total Cols: " . $intCols , "<br>Total Results: " . $intResCount;
# $rsfnGEDarr = mysqli_fetch_array($EventData);
# $GEDretVal = $rsfnGEDarr[1][1];
$rsfnGED = mysqli_fetch_array($EventData, MYSQL_ASSOC);
#printf("%s (%s)\n", $rsfnGED[0],$rsfnGED[4]);
#$row = mysqli_fetch_row($EventData);
$keys = @array_keys($rsfnGED);
$GEDretVal = $rsfnGED[$keys[$intColIndex]];
} else {
echo "Requested ColumnID does not exist";
die;
}
mysqli_close($linkged);
return $GEDretVal;
}
示例3: dump_properties
function dump_properties($mysqli)
{
printf("\nClass variables:\n");
$variables = array_keys(get_class_vars(get_class($mysqli)));
sort($variables);
foreach ($variables as $k => $var) {
printf("%s = '%s'\n", $var, var_export(@$mysqli->{$var}, true));
}
printf("\nObject variables:\n");
$variables = array_keys(get_object_vars($mysqli));
foreach ($variables as $k => $var) {
printf("%s = '%s'\n", $var, var_export(@$mysqli->{$var}, true));
}
printf("\nMagic, magic properties:\n");
assert(@mysqli_affected_rows($mysqli) === @$mysqli->affected_rows);
printf("mysqli->affected_rows = '%s'/%s ('%s'/%s)\n", @$mysqli->affected_rows, gettype(@$mysqli->affected_rows), @mysqli_affected_rows($mysqli), gettype(@mysqli_affected_rows($mysqli)));
assert(@mysqli_get_client_info() === @$mysqli->client_info);
printf("mysqli->client_info = '%s'/%s ('%s'/%s)\n", @$mysqli->client_info, gettype(@$mysqli->client_info), @mysqli_get_client_info(), gettype(@mysqli_get_client_info()));
assert(@mysqli_get_client_version() === @$mysqli->client_version);
printf("mysqli->client_version = '%s'/%s ('%s'/%s)\n", @$mysqli->client_version, gettype(@$mysqli->client_version), @mysqli_get_client_version(), gettype(@mysqli_get_client_version()));
assert(@mysqli_errno($mysqli) === @$mysqli->errno);
printf("mysqli->errno = '%s'/%s ('%s'/%s)\n", @$mysqli->errno, gettype(@$mysqli->errno), @mysqli_errno($mysqli), gettype(@mysqli_errno($mysqli)));
assert(@mysqli_error($mysqli) === @$mysqli->error);
printf("mysqli->error = '%s'/%s ('%s'/%s)\n", @$mysqli->error, gettype(@$mysqli->error), @mysqli_error($mysqli), gettype(@mysqli_error($mysqli)));
assert(@mysqli_field_count($mysqli) === @$mysqli->field_count);
printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n", @$mysqli->field_count, gettype(@$mysqli->field_count), @mysqli_field_count($mysqli), gettype(@mysqli_field_count($mysqli)));
assert(@mysqli_insert_id($mysqli) === @$mysqli->insert_id);
printf("mysqli->insert_id = '%s'/%s ('%s'/%s)\n", @$mysqli->insert_id, gettype(@$mysqli->insert_id), @mysqli_insert_id($mysqli), gettype(@mysqli_insert_id($mysqli)));
assert(@mysqli_sqlstate($mysqli) === @$mysqli->sqlstate);
printf("mysqli->sqlstate = '%s'/%s ('%s'/%s)\n", @$mysqli->sqlstate, gettype(@$mysqli->sqlstate), @mysqli_sqlstate($mysqli), gettype(@mysqli_sqlstate($mysqli)));
assert(@mysqli_get_host_info($mysqli) === @$mysqli->host_info);
printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n", @$mysqli->host_info, gettype(@$mysqli->host_info), @mysqli_get_host_info($mysqli), gettype(@mysqli_get_host_info($mysqli)));
/* note that the data types are different */
assert(@mysqli_info($mysqli) == @$mysqli->info);
printf("mysqli->info = '%s'/%s ('%s'/%s)\n", @$mysqli->info, gettype(@$mysqli->info), @mysqli_info($mysqli), gettype(@mysqli_info($mysqli)));
assert(@mysqli_thread_id($mysqli) > @$mysqli->thread_id);
assert(gettype(@$mysqli->thread_id) == gettype(@mysqli_thread_id($mysqli)));
printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n", @$mysqli->thread_id, gettype(@$mysqli->thread_id), @mysqli_thread_id($mysqli), gettype(@mysqli_thread_id($mysqli)));
assert(@mysqli_get_proto_info($mysqli) === @$mysqli->protocol_version);
printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n", @$mysqli->protocol_version, gettype(@$mysqli->protocol_version), @mysqli_get_proto_info($mysqli), gettype(@mysqli_get_proto_info($mysqli)));
assert(@mysqli_get_server_info($mysqli) === @$mysqli->server_info);
printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n", @$mysqli->server_info, gettype(@$mysqli->server_info), @mysqli_get_server_info($mysqli), gettype(@mysqli_get_server_info($mysqli)));
assert(@mysqli_get_server_version($mysqli) === @$mysqli->server_version);
printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n", @$mysqli->server_version, gettype(@$mysqli->server_version), @mysqli_get_server_version($mysqli), gettype(@mysqli_get_server_version($mysqli)));
assert(@mysqli_warning_count($mysqli) === @$mysqli->warning_count);
printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n", @$mysqli->warning_count, gettype(@$mysqli->warning_count), @mysqli_warning_count($mysqli), gettype(@mysqli_warning_count($mysqli)));
printf("\nAccess to undefined properties:\n");
printf("mysqli->unknown = '%s'\n", @$mysqli->unknown);
@($mysqli->unknown = 13);
printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
$unknown = 'friday';
@($mysqli->unknown = $unknown);
printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n");
assert(@mysqli_connect_error() === @$mysqli->connect_error);
printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n", @$mysqli->connect_error, gettype(@$mysqli->connect_error), @mysqli_connect_error(), gettype(@mysqli_connect_error()));
assert(@mysqli_connect_errno() === @$mysqli->connect_errno);
printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n", @$mysqli->connect_errno, gettype(@$mysqli->connect_errno), @mysqli_connect_errno(), gettype(@mysqli_connect_errno()));
}
示例4: grr_sql_query1
function grr_sql_query1($sql)
{
$r = mysqli_query($GLOBALS['db_c'], $sql);
if (!$r) {
return -1;
}
if (mysqli_num_rows($r) != 1 || mysqli_field_count($GLOBALS['db_c']) != 1 || ($result_ = mysqli_result($r, 0, 0)) == "") {
$result_ = -1;
}
mysqli_free_result($r);
return $result_;
}
示例5: do_download
function do_download()
{
$backup_name = 'LMT Backup ' . time() . '.sql';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $backup_name . '"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
cancel_templateify();
ob_clean();
flush();
echo 'CREATE DATABASE `lmt-bak` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;' . "\n" . 'USE `lmt-bak`;' . "\n\n\n";
$tables = array();
$result = DB::queryRaw('SHOW TABLES');
while ($row = mysqli_fetch_row($result)) {
$tables[] = $row[0];
}
foreach ($tables as $table) {
$result = DB::queryRaw('SELECT * FROM ' . $table);
$num_fields = mysqli_field_count($result);
echo 'DROP TABLE IF EXISTS ' . $table . ';';
$row2 = mysqli_fetch_row(DB::queryRaw('SHOW CREATE TABLE ' . $table));
echo "\n\n" . $row2[1] . ";\n\n";
for ($i = 0; $i < $num_fields; $i++) {
while ($row = mysqli_fetch_row($result)) {
echo 'INSERT INTO ' . $table . ' VALUES(';
for ($j = 0; $j < $num_fields; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
echo 'NULL';
} else {
$row[$j] = addslashes($row[$j]);
$row[$j] = preg_replace("\n", "\\n", $row[$j]);
echo '"' . $row[$j] . '"';
}
if ($j < $num_fields - 1) {
echo ',';
}
}
echo ");\n";
}
}
echo "\n\n\n";
}
}
示例6: die
die("Connection failed: " . $conn->connect_error);
}
//Grab the count of the number of cities PATIENTS
//SELECT city, id FROM femr.patients WHERE city NOT IN (SELECT name FROM mission_cities)
//SELECT city, id FROM femr.patients LIMIT 5
$patientCities = "SELECT city, id FROM femr.patients WHERE city NOT IN(SELECT name FROM mission_cities) LIMIT 5";
$resultQuery = $conn->query($patientCities);
$countQuery = mysqli_field_count($conn);
// while($row = $resultQuery->fetch_array()){
// for($i = 0; $i < $countQuery;$i++)
// echo $row[$i];
// }
//Grabbing the count of the cities DICTIONARY
$cityDictionary = "SELECT name FROM femr.mission_cities";
$resultQuery2 = $conn->query($cityDictionary);
$countQuery2 = mysqli_field_count($conn);
// while($row2 = $resultQuery2->fetch_array()){
// for($j = 0; $j < $countQuery2;$j++)
// echo $row[$j];
// }
?>
<div class="jumbotron"> <div class='container'>
<center><img align="middle" src="images/femrLogo.png"></img></center>
<center><h1> City Cleanse Results </h1></center>
<center><div class='row col-md-6 col-md-offset-2 custyle'></center>
<table class='table table-striped custab table-bordered'>
<thead>
<tr>
示例7: executeSQL
public function executeSQL($query, &$resultArry, &$rowsAffected, $assoc = TRUE)
{
$l_iTries = 3;
//times
$l_iPause = 2;
//seconds
$l_bConnected = FALSE;
//bool
do {
$link = mysqli_init();
$rowsAffected = 0;
if (!$link) {
throw new DBAdapter2Exception("mysqli_init failed");
}
if (!mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 5)) {
throw new DBAdapter2Exception("Setting MYSQLI_OPT_CONNECT_TIMEOUT failed");
}
if (!mysqli_real_connect($link, $this->host, $this->username, $this->password, $this->schema)) {
unset($link);
sleep($l_iPause);
$l_iTries = $l_iTries - 1;
} else {
$l_bConnected = TRUE;
$l_iTries = 0;
}
} while (!$l_bConnected && $l_iTries > 0);
if (!$l_bConnected) {
throw new DBAdapter2Exception('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
if (!mysqli_set_charset($link, $this->charset)) {
throw new DBAdapter2Exception('Error loading character set ' . $this->charset . ' - ' . mysqli_error($link));
}
//do queries
if (mysqli_real_query($link, $query)) {
//should be e proper select
if (mysqli_field_count($link)) {
//buffered
$result = mysqli_store_result($link);
if ($result) {
$resultArry = array();
$rowsAffected = mysqli_num_rows($result);
if ($assoc) {
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$resultArry[] = $row;
}
} else {
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
$resultArry[] = $row;
}
}
mysqli_free_result($result);
unset($result);
}
}
} else {
throw new DBAdapter2Exception('Error in query: ' . mysqli_error($link));
}
mysqli_close($link);
}
示例8: backup_tables_mysqli
function backup_tables_mysqli($host, $user, $pass, $name, $tables = '*')
{
$link = mysqli_connect($host, $user, $pass, $name);
/* Obtebemos las tablas */
if ($tables == '*') {
$tables = array();
$result = mysqli_query($link, 'SHOW TABLES');
while ($row = mysqli_fetch_row($result)) {
$tables[] = $row[0];
}
} else {
$tables = is_array($tables) ? $tables : explode(',', $tables);
}
/* generamos el contenido */
foreach ($tables as $table) {
$result = mysqli_query($link, 'SELECT * FROM ' . $table);
$num_fields = mysqli_field_count($link);
$return .= 'DROP TABLE ' . $table . ';';
$row2 = mysqli_fetch_row(mysqli_query($link, 'SHOW CREATE TABLE ' . $table));
$return .= "\n\n" . $row2[1] . ";\n\n";
for ($i = 0; $i < $num_fields; $i++) {
while ($row = mysqli_fetch_row($result)) {
$return .= 'INSERT INTO ' . $table . ' VALUES(';
for ($j = 0; $j < $num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n", "\\n", $row[$j]);
if (isset($row[$j])) {
$return .= '"' . $row[$j] . '"';
} else {
$return .= '""';
}
if ($j < $num_fields - 1) {
$return .= ',';
}
}
$return .= ");\n";
}
}
$return .= "\n\n\n";
}
/* Guardamos el archivo */
$handle = fopen('db-backup-' . time() . '-' . md5(implode(',', $tables)) . '.sql', 'w+');
if (fwrite($handle, $return)) {
fclose($handle);
echo "<script>alert('Archivo creado, descargalo desde la pagina principal')</script>";
} else {
echo "<script>alert('No se pudo descargar')</script>";
}
}
示例9: sql_num_fields
function sql_num_fields($type, $result, $con)
{
if ($type === 'mysql') {
if (function_exists('mysqli_field_count')) {
return mysqli_field_count($con);
} elseif (function_exists('mysql_num_fields')) {
return mysql_num_fields($result);
}
} elseif ($type === 'mssql') {
if (function_exists('mssql_num_fields')) {
return mssql_num_fields($result);
} elseif (function_exists('sqlsrv_num_fields')) {
return sqlsrv_num_fields($result);
}
} elseif ($type === 'pgsql') {
return pg_num_fields($result);
} elseif ($type === 'oracle') {
return oci_num_fields($result);
} elseif ($type === 'sqlite3') {
return $result->numColumns();
} elseif ($type === 'sqlite') {
return sqlite_num_fields($result);
} elseif ($type === 'odbc') {
return odbc_num_fields($result);
} elseif ($type === 'pdo') {
return $result->columnCount();
}
}
示例10: mysqli_real_escape_string
}
if ($_POST['ward'] != '0') {
$ward_sqlsafe = " AND Participants.Ward = '" . mysqli_real_escape_string($cnnSWOP, $_POST['ward']) . "' ";
} else {
$ward_sqlsafe = "";
}
$search_pool_sqlsafe = "SELECT * FROM Participants " . $status_sqlsafe . $join_inst_sqlsafe . $benchmarks_sqlsafe . $date_join_sqlsafe . $organizer_join_sqlsafe . $member_type_join_sqlsafe . "LEFT JOIN Participants_Properties ON Participants.Participant_ID=Participants_Properties.Participant_ID\r\n WHERE Participants.Participant_ID IS NOT NULL " . $institution_sqlsafe . $type_sqlsafe . $step_sqlsafe . $step_done_sqlsafe . $start_sqlsafe . $end_sqlsafe . $lag_sqlsafe . $organizer_sqlsafe . $first_name_sqlsafe . $last_name_sqlsafe . $email_sqlsafe . $phone_sqlsafe . $notes_sqlsafe . $date_of_birth_sqlsafe . $gender_sqlsafe . $has_itin_sqlsafe . $ward_sqlsafe . $language_spoken_sqlsafe;
//echo $search_pool . "<p>";
include "../include/dbconnopen.php";
$search_results = mysqli_query($cnnSWOP, $search_pool_sqlsafe);
?>
<table class="all_projects">
<caption>Choose the columns you would like to view and export for this query:</caption>
<?php
$num_columns = mysqli_field_count($cnnSWOP);
//echo $num_columns;
//this is brought over from PAWS. I'm trying to give Sarah what she wants in terms of checkboxes to determine which search fields will be
//returned.
$table = '';
for ($k = 0; $k < $num_columns; $k++) {
$get_column_names = mysqli_fetch_field_direct($search_results, $k);
//skip Name_Middle field
if ($get_column_names->name == "Name_Middle") {
continue;
}
if ($get_column_names->table != 'progress' && $get_column_names->table != 'laststatus') {
if ($get_column_names->table != $table) {
$table = $get_column_names->table;
?>
<tr class="note"><th colspan="4"><a href="javascript:;" onclick="
示例11: Query
/**
* Executes the given SQL query and returns the records
*
* @param string $sql The query string should not end with a semicolon
* @return object PHP 'mysql result' resource object containing the records
* on SELECT, SHOW, DESCRIBE or EXPLAIN queries and returns;
* TRUE or FALSE for all others i.e. UPDATE, DELETE, DROP
* AND FALSE on all errors (setting the local Error message)
*/
public function Query($sql)
{
$this->ResetError();
$this->last_sql = $sql;
$this->last_result = @mysqli_query($this->mysql_link, $sql);
if (!$this->last_result) {
$this->active_row = -1;
$this->SetError();
return false;
} else {
if (strpos(strtolower($sql), "insert") === 0) {
$this->last_insert_id = mysqli_insert_id($this->mysql_link);
if ($this->last_insert_id === false) {
$this->SetError();
return false;
} else {
$numrows = 0;
$this->active_row = -1;
return $this->last_result;
}
} else {
if (strpos(strtolower($sql), "select") === 0) {
$numrows = mysqli_field_count($this->mysql_link);
if ($numrows > 0) {
$this->active_row = 0;
} else {
$this->active_row = -1;
}
$this->last_insert_id = 0;
return $this->last_result;
} else {
return $this->last_result;
}
}
}
}
示例12: queryLastId
/**
* Executes query and Return new DBStatementI or int if this is INSERT statement
*
* @param $query
* @return DBStatementI|int
*/
public function queryLastId($query)
{
mysqli_select_db($this->_linkIdentifier, $this->_database);
if (static::$_debug) {
echo $query . "<br />\n";
}
$queryResult = mysqli_real_query($this->_linkIdentifier, $query);
$mysqli_field_count = mysqli_field_count($this->_linkIdentifier);
if ($mysqli_field_count) {
$result = mysqli_store_result($this->_linkIdentifier);
} else {
$result = $queryResult;
}
if ($result === true && preg_match('/^\\s*"?(INSERT|REPLACE)\\s+/i', $query)) {
$insertId = (int) $this->insertId();
return $insertId;
}
return new DBStatementI($result);
}
示例13: fieldsCount
/**
* フィールド数を取得
*
* @return int|null
*/
public function fieldsCount()
{
if ($this->mysql_mode == MYSQL_MODE_MYSQL) {
return mysql_num_fields($this->linkId);
} else {
if ($this->mysql_mode == MYSQL_MODE_MYSQLI) {
return mysqli_field_count($this->linkId);
}
}
return null;
}
示例14: use_or_store_result
/**
* 結果データを構築する
*
* 結果セットを取得する
* - 一括、逐次読み込みを任意に設定する場合は引数で指定する
* - デフォルトは一括読み込みとする
*
* @param boolean 結果セットを一括読み込みする場合TRUE
* @retrun boolean TRUE:成功時
*/
protected function use_or_store_result($store_result)
{
// 結果データを返さない場合はそのまま終了
if (mysqli_field_count($this->le_link) < 1) {
return TRUE;
}
// 結果データを取得
set_error_handler(array($this, 'php_error_handler'));
$le_result = $store_result ? mysqli_store_result($this->le_link) : mysqli_use_result($this->le_link);
restore_error_handler();
if ($le_result === FALSE) {
return FALSE;
}
// フィールド情報を取得する
foreach (mysqli_fetch_fields($le_result) as $field) {
$tmp = array(self::FIELD_DEF_IS_POS => count($this->def_fields), self::FIELD_DEF_IS_TYPE => $field->type, self::FIELD_DEF_IS_NAME => $field->name, self::FIELD_DEF_IS_NAME_ORIG => $field->orgname, self::FIELD_DEF_IS_TABLE => $field->table, self::FIELD_DEF_IS_TABLE_ORIG => $field->orgtable);
// MEMO : 底層レベルのバグでorgnameが取得できない場合がある
if (strlen($field->orgname) < 1) {
$this->def_fields[$field->name] = $tmp;
} else {
$this->def_fields[$field->orgname] = $tmp;
}
}
$this->le_result = $le_result;
$this->affected_rows = mysqli_num_rows($le_result);
}
示例15: getLengthFields
public function getLengthFields($rs)
{
return @mysqli_field_count($rs);
}