本文整理汇总了PHP中mysqli_fetch_object函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_fetch_object函数的具体用法?PHP mysqli_fetch_object怎么用?PHP mysqli_fetch_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_fetch_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verify_email
function verify_email($user, &$result)
{
$dbhost = 'localhost';
$dbusername = 'root';
/*usuario de base de datos*/
$dbuserpass = '';
/*contraseña, la deje en blanco para pruebas*/
$dbname = 'practicantes';
/*nombre de la base de datos*/
$con = mysqli_connect($dbhost, $dbusername, $dbuserpass) or die("Error al intentar conectarse a la BD");
/*creamos el enlace a la bd*/
if (!$con) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
$sql = "SELECT email FROM usuarios WHERE email='{$user}'";
$rec = mysqli_query($con, $sql);
$count = 0;
while ($row = mysqli_fetch_object($rec)) {
$count++;
$result = $row;
}
if ($count == 1) {
return 1;
} else {
return 0;
}
}
示例2: __construct
function __construct($username, $password, $tenantID)
{
if (strlen($username) == 0 || strlen($password) == 0) {
throw new Exception("Invalid username or password.");
}
$userDetails = User::getUserDetails($username);
if ($userDetails["active"] == 0) {
throw new Exception("This user account is inactive. Please check your email for activation instructions.");
} else {
$saltedPassword = Utility::saltAndHash($password, $userDetails["password"]);
//echo 'salted:' . $saltedPassword;
//echo Utility::saltAndHash($password);
$query = 'call validateUser(' . Database::queryString($username);
$query .= ',' . Database::queryString($saltedPassword);
$query .= ',' . Database::queryNumber($tenantID) . ');';
$result = Database::executeQuery($query);
if (!$result) {
throw new Exception('Unable to validate that username/password combination.');
} else {
$userid = 0;
while ($o = mysqli_fetch_object($result)) {
$userid = $o->userid;
$name = $o->name;
}
if ($userid > 0) {
$this->id = $userid;
$this->name = $name;
} else {
throw new Exception("Unable to validate that username/password combination.");
}
}
}
}
示例3: get_all_server
static function get_all_server()
{
$db = mysqli_connect($_SESSION['db_host'], $_SESSION['db_user'], $_SESSION['db_password'], $_SESSION['db_database']);
$result = mysqli_query($db, "SELECT * FROM `server` where test_system != 'true'");
while ($row = mysqli_fetch_object($result)) {
$i = $row->server_id;
$obj_name = "server" . $i;
${$obj_name} = new server();
${$obj_name}->server_id = $row->server_id;
${$obj_name}->hostname = $row->hostname;
# Fra Space
$result2 = mysqli_query($db, "SELECT * FROM `system_parameter` WHERE `server_id` = {$row->server_id} and `parameter_name` = 'fra-space' order by time desc");
while ($row2 = mysqli_fetch_object($result2)) {
${$obj_name}->fra_space = $row2->value_string;
}
# Fra Used Space
$result2 = mysqli_query($db, "SELECT * FROM `system_parameter` WHERE `server_id` = {$row->server_id} and `parameter_name` = 'fra-used-space' order by time desc");
while ($row2 = mysqli_fetch_object($result2)) {
${$obj_name}->fra_used_space = $row2->value_string;
}
# Build all instance objects
${$obj_name}->instances = instance_actions::get_instance_by_server($row->hostname);
$arr_obj[] = ${$obj_name};
}
return $arr_obj;
}
示例4: retourneDevoirs
function retourneDevoirs($ele_login)
{
$date_ct1 = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
// On récupère tous les devoirs depuis aujourd'hui 00:00:00
$sql = "SELECT DISTINCT ctde.* FROM ct_devoirs_entry ctde, j_eleves_groupes jeg\r\n\t\t\t\t\t\t\t\tWHERE ctde.id_groupe = jeg.id_groupe\r\n\t\t\t\t\t\t\t\tAND jeg.login = '" . $ele_login . "'\r\n\t\t\t\t\t\t\t\tAND ctde.date_ct >= '" . $date_ct1 . "'\r\n\t\t\t\t\t\t\tORDER BY ctde.date_ct, ctde.id_groupe;";
//echo "$sql<br />";
$res_ct = mysqli_query($GLOBALS["mysqli"], $sql);
$cpt2 = 0;
// on initialise un compteur pour le while
if (mysqli_num_rows($res_ct) > 0) {
while ($lig_ct = mysqli_fetch_object($res_ct)) {
$tab_ele['cdt_dev'][$cpt2] = array();
$tab_ele['cdt_dev'][$cpt2]['id_ct'] = $lig_ct->id_ct;
$tab_ele['cdt_dev'][$cpt2]['id_groupe'] = $lig_ct->id_groupe;
$tab_ele['cdt_dev'][$cpt2]['date_ct'] = $lig_ct->date_ct;
$tab_ele['cdt_dev'][$cpt2]['id_login'] = $lig_ct->id_login;
$tab_ele['cdt_dev'][$cpt2]['contenu'] = $lig_ct->contenu;
$cpt2++;
}
$tab_ele['cdt_dev']['count'] = $cpt2;
} else {
$tab_ele['cdt_dev']['count'] = 0;
}
return $tab_ele;
}
示例5: fetchObj
public function fetchObj()
{
if ($this->_result) {
return $this->_row = mysqli_fetch_object($this->_result);
}
return false;
}
示例6: datapages
function datapages()
{
if ($_SESSION['userinfo']['status'] === 1) {
$conn = new mysqli('localhost', 'root', '12345password12345', 'main');
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$num_rows_res = $conn->query("SELECT count(*) FROM mlib;");
$num_rows = mysqli_fetch_array($num_rows_res, MYSQLI_NUM)[0];
for ($i = 1; $i <= $num_rows; $i++) {
$pages_sql = "Select * FROM mlib WHERE c_id=" . $i . ";";
$pages_res = $conn->query($pages_sql);
$pages[$i] = mysqli_fetch_object($pages_res);
}
$conn->close();
} else {
$conn = new mysqli('localhost', 'root', '12345password12345', 'main');
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$num_rows_res = $conn->query("SELECT count(*) FROM mlib WHERE viewers='all';");
$num_rows = mysqli_fetch_array($num_rows_res, MYSQLI_NUM)[0];
for ($i = 1; $i <= $num_rows; $i++) {
$pages_sql = "Select * FROM mlib WHERE c_id=" . $i . " AND viewers='all';";
$pages_res = $conn->query($pages_sql);
$pages[$i] = mysqli_fetch_object($pages_res);
}
$conn->close();
}
return $pages;
}
示例7: getGcmIds
function getGcmIds($link, $id)
{
$query = "SELECT user_gcm_id FROM device_user WHERE user_id = '{$id}'";
$resultado = mysqli_query($link, $query) or die("Erro na consulta: " . mysqli_error($link));
$gcId = mysqli_fetch_object($resultado);
return $gcId->user_gcm_id;
}
示例8: listDbData
function listDbData()
{
$link = mysqli_connect('localhost', 'root', '') or die(mysql_error());
$db_list = mysql_list_dbs($link);
print "<table width=100% bgcolor='BLACK' cellspacing=1 cellpadding=0>";
print "<tr bgcolor=#BBBBBB><td align='center'>";
print "<b>Database list</b>";
print "</td></tr>";
while ($row = mysqli_fetch_object($link, $db_list)) {
print "<tr bgcolor='WHITE'><td align='center'>";
print $row->Database;
//echo $row->Database . "<br>";
print "</td></tr>";
}
print "<tr bgcolor=#BBBBBB><td align='center'>";
print "<b>Tables</b>";
print "</td></tr>";
$db_selected = mysqli_select_db('maxinedb', $link);
$sql = "SHOW TABLES";
$result = mysqli_query($link, $sql);
if (!$result) {
throw new man_exception('MySQL Error: ' . mysql_error());
}
while ($row = mysqli_fetch_row($link, $result)) {
print "<tr bgcolor='WHITE'><td align='center'>";
print $row[0] . "";
print "</td></tr>";
}
print "</table>";
}
示例9: replaceEntityURLs
static function replaceEntityURLs(&$object)
{
global $wpdb;
self::mapObjects($object);
$urls = implode("','", array_map(function ($e) {
return addslashes($e[0]->singleUrl);
}, array_filter(self::$objects, function ($e) {
return (bool) $e[0]->singleUrl;
})));
$query = "SELECT post_ID, meta_value FROM {$wpdb->postmeta} WHERE meta_value IN('{$urls}')";
if ($wpdb->use_mysqli) {
$rs = mysqli_query($wpdb->dbh, $query);
while ($obj = @mysqli_fetch_object($rs)) {
$post_permalink = get_permalink($obj->post_ID);
if (isset(self::$objects[$obj->meta_value]) && is_array(self::$objects[$obj->meta_value])) {
foreach (self::$objects[$obj->meta_value] as $o) {
$o->singleUrl = $post_permalink;
}
}
}
} else {
$rs = mysql_query($query);
while ($obj = @mysql_fetch_object($rs)) {
$post_permalink = get_permalink($obj->post_ID);
if (isset(self::$objects[$obj->meta_value]) && is_array(self::$objects[$obj->meta_value])) {
foreach (self::$objects[$obj->meta_value] as $o) {
$o->singleUrl = $post_permalink;
}
}
}
}
}
示例10: MessageGetInfo
function MessageGetInfo($idMessage)
{
$query = "SELECT * FROM `message` WHERE `idMessage`='{$idMessage}';";
$result = QueryExcuteWhile($query);
$o = mysqli_fetch_object($result);
return $o;
}
示例11: verif_proportion_garcons_filles
function verif_proportion_garcons_filles()
{
global $projet;
$retour = "";
$sql = "SELECT DISTINCT classe FROM gc_divisions WHERE projet='{$projet}' AND statut='future' ORDER BY classe;";
$res = mysqli_query($GLOBALS["mysqli"], $sql);
if (mysqli_num_rows($res) > 0) {
while ($lig = mysqli_fetch_object($res)) {
$sql = "SELECT 1=1 FROM gc_eleves_options geo, eleves e WHERE projet='" . $projet . "' AND classe_future='" . $lig->classe . "' AND e.sexe='F' AND geo.login=e.login;";
$res_f = mysqli_query($GLOBALS["mysqli"], $sql);
$eff_f = mysqli_num_rows($res_f);
$sql = "SELECT 1=1 FROM gc_eleves_options geo, eleves e WHERE projet='" . $projet . "' AND classe_future='" . $lig->classe . "' AND e.sexe='M' AND geo.login=e.login;";
$res_m = mysqli_query($GLOBALS["mysqli"], $sql);
$eff_m = mysqli_num_rows($res_m);
$eff_total = $eff_m + $eff_f;
if ($eff_total >= 20) {
if ($eff_f / $eff_total >= 2 / 3) {
$retour .= "<br /><strong>ATTENTION :</strong> La sélection courante de {$lig->classe} présente plus de 2/3 de filles.";
} elseif ($eff_m / $eff_total >= 2 / 3) {
$retour .= "<br /><strong>ATTENTION :</strong> La sélection courante de {$lig->classe} présente plus de 2/3 de garçons.";
}
}
}
}
return $retour;
}
示例12: handleForm
function handleForm()
{
global $db;
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$role = $_POST['role'];
$f = $s = $e = $r = "";
if (isset($_POST['save'])) {
//save one record
$statement = "INSERT INTO users (firstname, lastname, email, type) VALUES\n ('{$firstname}','{$lastname}','{$email}','{$role}')";
if ($result = mysqli_query($db, $statement)) {
echo "<h3 style='color: green'>One row added to the database</h3>";
} else {
echo "<h3 style='color: red'>There was a problem saving your data</h3>";
}
} elseif (isset($_POST['amend'])) {
//alter one record
$statement = "UPDATE users SET firstname='{$firstname}', lastname='{$lastname}', type='{$role}' WHERE email='{$email}'";
if ($result = mysqli_query($db, $statement)) {
echo "<h3 style='color: green'>Database updated successfully</h3>";
} else {
echo "<h3 style='color: red'>There was a problem updating your data</h3>";
}
} elseif (isset($_POST['delete'])) {
//delete one record
$statement = "DELETE FROM users WHERE email='{$email}'";
if ($result = mysqli_query($db, $statement)) {
echo "<h3 style='color: green'>One row deleted from the database</h3>";
} else {
echo "<h3 style='color: red'>There was a problem deleting your data. Make sure that you entered the correct email address.</h3>";
}
} elseif (isset($_POST['view'])) {
//view one record
$statement = "SELECT * FROM users WHERE email='{$email}'";
if ($result = mysqli_query($db, $statement)) {
echo "<h3>Your query returned</h3>";
$data = mysqli_fetch_object($result);
$f = $data->firstname;
$s = $data->lastname;
$e = $data->email;
$r = $data->type;
} else {
echo "<h3 style='color: red'>There was a problem finding the row. Please check that you entered the correct email address</h3>";
}
} else {
//must be showall
$statement = "SELECT * FROM users";
if ($result = mysqli_query($db, $statement)) {
echo "<h3>Your query returned</h3><table border='1'>";
while ($data = mysqli_fetch_object($result)) {
echo "<tr><td>{$data->firstname}</td><td>{$data->lastname}</td>\n <td>{$data->email}</td><td>{$data->type}</td></tr>";
}
echo "</table>";
} else {
echo "<h3 style='color: red'>There was a problem retrieving data.</h3>";
}
}
printForm($f, $s, $e, $r);
}
示例13: buildPage
function buildPage()
{
global $mysql;
$MySQLConnection = new Mysql($mysql['host'], $mysql['port'], $mysql['user'], $mysql['password'], $mysql['database']);
$MySQLConnection->connect();
if ($result = $MySQLConnection->getQuery('SELECT messageID, messageRecipient, messageSender, messageTime, messageSubject, messageBody, userLogin, userID FROM messages JOIN users ON messageSender = userID WHERE messageRecipient = ' . $_SESSION["userID"] . ' LIMIT 0,25;')) {
echo '
<div class="col-md-2">
';
while ($row = mysqli_fetch_object($result)) {
$messageJSON = (string) json_encode($row);
echo '
<div class="list-group">
<a href="#" onclick="displayMessage(\'' . $row->messageID . '\');"" class="list-group-item">
<p class="list-group-item-text">' . $row->messageTime . ' - ' . $row->userLogin . '</p>
<h4 class="list-group-item-heading">' . $row->messageSubject . '</h4>
</a>
</div>
';
}
echo '</div>';
} else {
echo '<script type="text/javascript">', 'printError(\'Error while getting your messages!\')', '</script>';
}
}
示例14: login
function login($user, $password, &$result)
{
$dbhost = 'localhost';
$dbusername = 'root';
/*usuario de base de datos*/
$dbuserpass = '';
/*contraseña, la deje en blanco para pruebas*/
$dbname = 'practicantes';
/*nombre de la base de datos*/
$con = mysqli_connect($dbhost, $dbusername, $dbuserpass, $dbname);
if (!$con) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
$sql = "SELECT usuario, password FROM usuarios WHERE usuario='" . $user . "' AND password='" . $password . "';";
$rec = mysqli_query($con, $sql);
$count = 0;
while ($row = mysqli_fetch_object($rec)) {
$count++;
$result = $row;
}
if ($count == 1) {
return 1;
} else {
return 0;
}
}
示例15: look_config_default_values
function look_config_default_values($field_name, $like = '', $default_values = '')
{
if ($like == '') {
$sql = "select NAME,IVALUE,TVALUE,COMMENTS from config where NAME in ";
$arg_sql = array();
$arg = mysql2_prepare($sql, $arg_sql, $field_name);
} else {
$arg['SQL'] = "select NAME,IVALUE,TVALUE,COMMENTS from config where NAME like '%s'";
$arg['ARG'] = $field_name;
}
$resdefaultvalues = mysql2_query_secure($arg['SQL'], $_SESSION['OCS']["readServer"], $arg['ARG']);
while ($item = mysqli_fetch_object($resdefaultvalues)) {
$result['name'][$item->NAME] = $item->NAME;
$result['ivalue'][$item->NAME] = $item->IVALUE;
$result['tvalue'][$item->NAME] = $item->TVALUE;
$result['comments'][$item->NAME] = $item->COMMENTS;
}
if (is_array($default_values)) {
foreach ($default_values as $key => $value) {
$key = strtolower($key);
if (is_array($value)) {
foreach ($value as $name => $val) {
if (!isset($result[$key][$name]) or $result[$key][$name] == '') {
$result[$key][$name] = $val;
}
}
}
}
}
return $result;
}