本文整理汇总了PHP中DBConnection::select方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnection::select方法的具体用法?PHP DBConnection::select怎么用?PHP DBConnection::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnection
的用法示例。
在下文中一共展示了DBConnection::select方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchAll
static function fetchAll()
{
DBConnection::connect();
$result = DBConnection::select('SELECT * FROM post');
$posts = [];
if ($result) {
foreach ($result as $post) {
array_push($posts, new Post($post->id, $post->title, false));
}
}
return $posts;
}
示例2: fetchAll
static function fetchAll()
{
DBConnection::connect();
$result = DBConnection::select('SELECT * FROM user');
$users = [];
if ($result) {
foreach ($result as $user) {
array_push($users, new User($user->id, $user->pseudo, false));
}
}
return $users;
}
示例3: getDataFromDBWithHosLog
public function getDataFromDBWithHosLog($HosLog)
{
$data = DBConnection::select("Select * from hospede WHERE HosLog='" . $HosLog . "'");
foreach ($data as $row) {
$this->nome = $row['HosNom'];
$this->login = $row['HosLog'];
$this->senha = $row['HosPas'];
$this->email = $row['HosEma'];
$this->endereco = $row['HosEnd'];
$this->cidade = $row['HosCid'];
$this->pais = $row['HosPai'];
$this->telefone = $row['HosTel'];
$this->documento = $row['HosDoc'];
}
}
示例4: ReservaData
<?php
/**
* Created by PhpStorm.
* User: GabrielAguiar
* Date: 24/05/14
* Time: 14:51
*/
$arriveDate = $_POST['postarrive'];
$avaliable = false;
$leaveDate = $_POST['postleave'];
$number = $_POST['postnumber'];
$data = DBConnection::select("SELECT * FROM reserva WHERE ResArr between '" . $arriveDate . "' and '" . $leaveDate . "'");
$i = 0;
$newRes = new ReservaData();
$newRes->maxSingle -= $number;
$newRes->maxCouple -= $number / 2;
$newRes->maxLux -= $number;
foreach ($data as $row) {
if ($row['ResTip'] == 1) {
$newRes->maxSingle--;
}
if ($row['ResTip'] == 2) {
$newRes->maxCouple--;
}
if ($row['ResTip'] == 3) {
$newRes->maxLux--;
}
}
echo "<div style='color:white; width:91%; margin-top:10px; float:left;'class='gallery items-3'>";
if ($newRes->maxSingle > 0) {
示例5:
<?php
$login = $_POST['postlogin'];
$pass = $_POST['postpass'];
$tuts = 0;
echo "<script>alert('HI')</script>";
$data = DBConnection::select("SELECT * FROM hospede");
foreach ($data as $row) {
if ($row['HosLog'] == $login && $row['HosPas'] == $pass) {
session_start();
$_SESSION['username'] = $row['HosLog'];
$_SESSION['password'] = $row['HosPas'];
$_SESSION['adm'] = $row['HosAdm'];
$_SESSION['wrongLogin'] = false;
$tuts = 1;
}
}
if (!$tuts) {
session_start();
$_SESSION['wrongLogin'] = true;
}
示例6: DBConnection
<?php
require_once '../model/DBConnection.php';
$db = new DBConnection();
/*
* INSERT TEST.
*/
$lastInsertedId = $db->insert('truck', array('vehicle_capacity' => 0, 'brand' => 'Scania', 'age' => 4));
echo '<p> Last Inserted ID: ' . $lastInsertedId . '</p>';
/*
* SELECT SINGLE TEST.
*/
echo '<p> All columns: ';
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
echo '<p> Some columns: ';
var_dump($db->select('truck', array('brand', 'age'), 'id', $lastInsertedId));
echo '</p>';
/*
* SELECT ALL TEST.
*/
$db->insert('truck', array('brand' => 'Mercedes', 'age' => 3));
echo '<p> All rows and columns: ';
var_dump($db->select('truck', '*'));
/*
* UPDATE TEST.
*/
echo '<p> Before update: ';
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
$db->update('truck', array('vehicle_capacity' => 0, 'brand' => 'MAN', 'age' => 0), $lastInsertedId);
示例7: hospede
});
}
</script>
<?php
$login = $_POST['postlogin'];
$name = $_POST['postname'];
$password = $_POST['postpass'];
$email = $_POST['postemail'];
$endereco = $_POST['postendereco'];
$cidade = $_POST['postcidade'];
$telefone = $_POST['posttelefone'];
$documento = $_POST['postdocumento'];
$pais = $_POST['postpais'];
$loginStats = false;
$emailStats = false;
$data = DBConnection::select("Select * from hospede");
foreach ($data as $row) {
if ($row['HonLog'] == $login) {
$loginStats = true;
}
if ($row['HonEma'] == $email) {
$loginStats = true;
}
}
if ($loginStats) {
echo "<script>signUp2()</script>";
} else {
DBConnection::insert('Insert INTO hospede (HosNom,HosLog,HosPas,HosEma,HosEnd,HosCid,HosTel,HosDoc,HosPai) values("' . $name . '","' . $login . '","' . $password . '","' . $email . '","' . $endereco . '","' . $cidade . '","' . $telefone . '","' . $documento . '","' . $pais . '")');
}
示例8: count
/**
* Count how many instances of this type reside in the database. If WHERE
* condition is provided, only instances that correspond with the condition
* will be counted.
* @param string|array(string) $where Optional.
* @param string|array(string) $value Optional.
* @return int
*/
public function count($where = null, $value = null)
{
$db = new DBConnection();
$data = null;
if ($where && $value) {
$data = $db->select($this->convert_to_table_name($this->get_class_name()), 'COUNT(id)', $where, $value);
} else {
$data = $db->select($this->convert_to_table_name($this->get_class_name()), 'COUNT(id)');
}
return intval($data[0]['COUNT(id)']);
}