本文整理汇总了PHP中DataBase类的典型用法代码示例。如果您正苦于以下问题:PHP DataBase类的具体用法?PHP DataBase怎么用?PHP DataBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public function get($id)
{
require_once 'DataBase.php';
$data = new DataBase();
$data->open();
$sql = "BEGIN GETRUTACONDUCTOR(:p_id, :rc); END;";
$sent = oci_parse($data->getConn(), $sql);
$refcur = oci_new_cursor($data->getConn());
$this->id = $id;
oci_bind_by_name($sent, ':p_id', $this->id);
oci_bind_by_name($sent, ':rc', $refcur, -1, OCI_B_CURSOR);
if (!oci_execute($sent)) {
return false;
}
if (!oci_execute($refcur)) {
return false;
}
while (($row = oci_fetch_array($refcur, OCI_ASSOC + OCI_RETURN_NULLS)) != false) {
$this->ruta = $row['ID_RUTA'];
$this->conductor = $row['ID_CONDUCTOR'];
$this->kilometraje = $row['KILOMETRAJE'];
$this->descripcion = $row['DESCRIPCION'];
}
oci_free_statement($refcur);
$data->free($sent);
$data->close();
return true;
}
示例2: loadAtendente
function loadAtendente()
{
include_once 'app.ado/DataBase.php';
$db = new DataBase();
$aten = $db->getConn()->query('select nome_usuario from usuarios where id_usuario = ' . $this->usuario_id . ';')->fetchAll(PDO::FETCH_CLASS, "Item");
return $aten;
}
示例3: render
public function render()
{
if (!$this->conteudo) {
include_once 'app.ado/DataBase.php';
$pdo = new DataBase();
$db = $pdo->getConn();
$sql = 'select * from ctrl_chaves';
if ($this->dt_inicial or $this->dt_final) {
$this->dt_inicial = $this->dt_inicial ? $this->dt_inicial : '2012/01/01';
$this->dt_final = $this->dt_final ? $this->dt_final : date('Y/m/d');
$sql .= ' where ((dt_inicial_controle between ? and ?) or (dt_final_controle between ? and ?))';
$exec[] = $this->dt_inicial;
$exec[] = $this->dt_final;
if ($this->id) {
$sql .= ' and id_controle = ?';
$exec[] = $this->id;
}
} elseif ($this->id) {
$sql .= ' where id_controle = ?';
$exec[] = $this->id;
}
if ($this->order) {
$sql .= ' order by ?';
$exec[] = $this->order;
}
$sth = $db->prepare($sql);
$conteudo = $sth->execute($exec);
$this->conteudo = $conteudo->fetchAll(PDO::FETCH_CLASS, 'CrlChave');
}
$tabela = new TTableChave($this->conteudo);
$pdf = new TRelatorio();
$pdf->writeHTML($tabela->render());
$pdf->render();
$pdf->exit();
}
示例4: getTable
function getTable($news_id, $hotelType, $hotelLocation, $impactType)
{
$mydatabase = new DataBase();
//$news = $mydatabase->getNews_by_game($game,$period);
$news = $mydatabase->getNews_by_id($news_id);
//print_r("Game: ".$game.", Period: ".$period);
if (!isset($news) || count($news) == 0) {
return "fail";
}
$parameters = $mydatabase->getAllNews_parameters($news['id']);
$count = 0;
$result = '<h3 align="center"> News Affects Parameters</h3>' . '<br />' . '<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>Hotel Type</th>
<th>Hotel Location</th>
<th>Impact</th>
</tr>
</thead>';
if (isset($parameters) && count($parameters) > 0) {
foreach ($parameters as $key => $temp) {
$result .= "<tbody>" . "<tr>" . "<td>" . ++$count . "</td>" . "<td>" . $temp['hotel_type'] . "</td>" . "<td>" . $mydatabase->getLocation($temp['hotel_location'])['type'] . "</td>" . "<td>" . $temp['effect'] . "</td>" . "</tr>" . "</tbody>";
}
}
if (isset($hotelType) && isset($hotelLocation) && isset($impactType)) {
for ($counter = 0; $counter < count($impactType); $counter++) {
$result .= "<tbody>" . "<tr>" . "<td>" . ($counter + 1 + $count) . "</td>" . "<td>" . $hotelType[$counter] . "</td>" . "<td>" . $hotelLocation[$counter] . "</td>" . "<td>" . $impactType[$counter] . "</td>" . "</tr>" . "</tbody>";
}
}
$result .= "</table><br />";
return $result;
}
示例5: search_matrix
public function search_matrix($idMatrix = FALSE)
{
$objData = new DataBase();
$sth = $objData->prepare('SELECT * FROM matrix M inner join users U ' . 'on M.id_matrix = U.id_matrix WHERE M.id_matrix = :idMatrix');
$sth->execute(array(':idMatrix' => $idMatrix));
return $result = $sth->fetchAll();
}
示例6: PollMessage
function PollMessage()
{
include 'config/config.php';
require_once 'libs/database.php';
$db = new DataBase($db_server, $db_user, $db_password);
$db->Select($db_name);
$db->Query("SELECT * FROM messages ORDER BY id DESC LIMIT 2");
$data = $db->ReadNext();
//no message in queue - return nop
if ($data == null) {
echo "none";
return;
}
/* echo "<pre>";
print_r($data);
echo "</pre>";*/
$id = $data['id'];
$message = $data['message'];
//return the command to client
echo $message;
//delete message from queue
$db = new DataBase($db_server, $db_user, $db_password);
$db->Select($db_name);
$db->Query("DELETE FROM messages WHERE id = '{$id}';");
}
示例7: listaUnidades
public static function listaUnidades($sql)
{
$db = new DataBase();
$db->setQuery(" \n SELECT\n codUnidad\n , nombre\n FROM e_unidad\n WHERE {$sql}\n AND estado=2\n ");
//f::message($db->getQuery());
$db->executeQuery();
return $db->getTable('encode');
}
示例8: loadLaboratorio
function loadLaboratorio()
{
include_once 'app.ado/DataBase.php';
$db = new DataBase();
$lab = $db->getConn()->query('select nome_laboratorio from laboratorios where id_laboratorio = ' . $this->laboratorio_id . ';')->fetch(PDO::FETCH_COLUMN);
unset($db);
return $lab;
}
示例9: tearDown
function tearDown()
{
$db = new DataBase();
$db->Clear();
$db->Close();
unset($_SESSION['user']);
unset($_SESSION['pw']);
}
示例10: getCurrentUser
public static function getCurrentUser($id)
{
$class = static::class;
$sql = 'SELECT * FROM users WHERE id=:id';
$db = new DataBase();
$res = $db->findOne($class, $sql, [':id' => $id]);
return $res;
}
示例11: EnqueueMessage
function EnqueueMessage($message)
{
include 'config/config.php';
require_once 'libs/database.php';
$db = new DataBase($db_server, $db_user, $db_password);
$db->Select($db_name);
$query = "INSERT INTO messages (\n\t\t\t\t\tmessage\n\t\t\t\t\t)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t'{$message}'\n\t\t\t\t\t);";
$db->Query($query);
}
示例12: get_feed_items
public function get_feed_items()
{
$db = new DataBase();
$result = $db->get_all();
$feed = array();
foreach ($result as $feed_item) {
array_push($feed, new FeedItem($feed_item));
}
return $feed;
}
示例13: get_siteInfo
function get_siteInfo($TcName)
{
// Busca en la tabla de configuraciones el valor establecido
$query = "SELECT valor,tipo FROM Configuracion WHERE idConfiguracion = '{$TcName}'";
include_once './dataBaseClass/connection.php';
$cDb = new DataBase();
$result = $cDb->query($query);
$row = mysqli_fetch_assoc($result);
return $row["valor"];
}
示例14: insertNews
public function insertNews() {
$db = new DataBase();
//$db->setClassName(get_called_class());
$news = [];
foreach ($this->data['news'] as $key => $value) {
$news[] = '(' . $key . ', ' . $value . ')';
}
$sql = 'INSERT INTO ' . $this->table . '(Owner, Post) VALUES ' . implode(', ', array_values($news)) . ' ON DUPLICATE KEY UPDATE Owner = Owner';
return $db->execute($sql);
}
示例15: get_dataByLogin
function get_dataByLogin($login)
{
$db = new DataBase();
$mysqli = $db->getMysqli();
$sql = 'SELECT * FROM users WHERE login ="' . $login . '"';
if ($result = $mysqli->query($sql)) {
return $result->fetch_assoc();
} else {
return null;
}
}