本文整理汇总了PHP中DataBase::query方法的典型用法代码示例。如果您正苦于以下问题:PHP DataBase::query方法的具体用法?PHP DataBase::query怎么用?PHP DataBase::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBase
的用法示例。
在下文中一共展示了DataBase::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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"];
}
示例2: get_snapshot_category_by_cid
/**
* 根据时间戳和联系人ID获取快照分组名
* @param int $user_id 用户ID
* @param int $cid 联系人ID
* @param int $dateline 时间戳
* @return string
*/
public function get_snapshot_category_by_cid($user_id, $cid, $dateline)
{
$sql = sprintf("SELECT category_id FROM %s WHERE uid = %d AND snapshot_id = %d AND cid = %d", $this->get_table($user_id, 'contact_classes_snapshot'), $user_id, $dateline, $cid);
$query = $this->db->query($sql);
if ($query->count()) {
$result = array();
$res = $query->result_array(FALSE);
foreach ($res as $val) {
$result[] = $val['category_id'];
}
return $result;
}
return array();
}
示例3: _get_info_list
/**
* 获取联系信息列表
* @param int $id 联系人ID
* @return array
*/
private function _get_info_list($id, $type = 'emails')
{
switch ($type) {
case 'tels':
$row = '`type`, `value`, `pref`, `city`';
break;
case 'addresses':
$row = '`type`, `country`, `postal`, `region`, `city`, `street`';
break;
case 'ims':
$row = '`protocol`, `type`, `value`';
break;
default:
$row = '`type`, `value`';
break;
}
$query = $this->db->query("SELECT {$row} FROM `gcp_{$type}` WHERE `gcid` = '{$id}' ORDER BY `id` ASC");
return $query->result_array(FALSE);
}
示例4: catch
<?php
try {
$allowGuest = $hideDefaultView = true;
require '../framework/inc.php';
} catch (Exception $e) {
die('Invalid DataBase informations <a href="javascript:window.history.back();">Launch installation wizard</a>');
}
try {
DataBase::query(file_get_contents('db-setup.sql'));
echo 'Please remove the <strong>install</strong> folder.<br /><a href="..">Done !</a>';
Page::setTitle('Installation Wizard');
Page::send();
} catch (Exception $e) {
echo '<h1>DataBase Error</h1>' . $e->message;
}
示例5: _findRelations
/**
* Find the related objects of the model
* @param $table The name of the table of the objects
* @param $conditions The relation conditions
* @return array Array of objects
*/
public function _findRelations($table, $conditions)
{
if (count($conditions) == 0) {
$query = "SELECT * FROM {$table}";
} else {
$query = "SELECT * FROM {$table} WHERE ( {$conditions} )";
}
$db2 = new DataBase();
$db2->query($query);
$numResults = $db2->numRows();
$results = array();
for ($i = 0; $i < $numResults; $i++) {
$result = $db2->fetchObject();
$results[] = new $table($result);
}
return $results;
}
示例6: header
<?php
session_start();
if (!isset($_SESSION['login_user']) || empty($_SESSION['login_user'])) {
header("Location: /Cobranza/index.php");
exit;
}
$idCliente = filter_input(INPUT_GET, 'id');
$nombre = filter_input(INPUT_GET, 'Nombre');
include './dataBaseClass/connection.php';
$cDb = new DataBase();
$result = $cDb->query("SELECT * FROM ExpedienteElectronico WHERE idCliente = {$idCliente}");
?>
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button
<h1 class="modal-title">Agregar Expediente al Cliente: <?php
echo $nombre;
?>
</h1>
</div>
<div class="modal-body" style="margin: 20px;">
<table id="tblExpedientes" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Id</th>
<th>Nombre Archivo</th>
<th>Acciones</th>
</tr>
示例7: array
if ($mail['sender'] == User::getID()) {
$r = DataBase::update('messages', array('sender_dir' => $_GET['dir']), array('ID' => $_GET['ID'], 'sender' => User::getID()))->fetch();
} else {
if ($mail['recipient'] == User::getID()) {
$r = DataBase::update('messages', array('recipient_dir' => $_GET['dir']), array('ID' => $_GET['ID'], 'recipient' => User::getID()))->fetch();
} else {
die('<h3>Mail not found</h3>');
}
}
} else {
die('<h3>That\'s not your mail !</h3>');
}
die('true');
break;
case 'unread':
$unread = DataBase::query('SELECT COUNT(*) FROM messages WHERE opened = 0 AND recipient_dir = ' . DataBase::_secure($_GET['folder']) . ' AND recipient = ' . User::getID())->fetch()[0];
if (strval($unread)) {
die($unread);
} else {
die;
}
break;
case 'send':
// check message HTML does not comport malicious tags
// for example with HTMLPurify PHP library
$recipient = DataBase::get('users', array('ID'), array('fullname' => $_POST['recipient']));
if (!count($recipient) || $recipient === false) {
die('false');
}
if (DataBase::insert('messages', array('sender' => User::getID(), 'recipient' => $recipient[0]['ID'], 'subject' => htmlspecialchars($_POST['subject']), 'content' => $_POST['content'], 'sent' => array('NOW()'), 'opened' => 0, 'answerTo' => 0, 'sender_dir' => 'sent', 'recipient_dir' => 'inbox'))) {
if (DataBase::insert('messages', array('sender' => User::getID(), 'recipient' => $recipient[0]['ID'], 'subject' => htmlspecialchars($_POST['subject']), 'content' => $_POST['content'], 'sent' => array('NOW()'), 'opened' => 0, 'answerTo' => 0, 'sender_dir' => 'sent', 'recipient_dir' => 'sent'))) {
示例8: delete
function delete($class, $where = "")
{
$temp_class = new $class();
$query = new Query($temp_class->__table__, "delete");
if ($where != "") {
$query->where = $where;
}
$db = new DataBase();
$db->connect();
//echo $query->build();
$res = $db->query($query);
return $res;
}
示例9: findOneByPK
public function findOneByPK()
{
$sql = 'SELECT * FROM ' . static::$table . ' WHERE id=:id';
$db = new DataBase();
return $db->query($sql, [':id' => $this->id])[0];
}
示例10: set_main
function set_main($photo, $i)
{
$r = new DataBase();
$r->query("DELETE FROM photo_main WHERE folder = '" . $photo['folder'] . "'");
$r->query("INSERT INTO photo_main (folder, count) VALUES('" . $photo['folder'] . "', " . $i . ")");
}
示例11: COUNT
require 'framework/inc.php';
Page::setTitle('Home');
?>
<div class="row">
<div class="col-lg-3">
<div class="widget style1 lazur-bg">
<div class="row">
<div class="col-xs-4">
<i class="fa fa-envelope-o fa-5x"></i>
</div>
<div class="col-xs-8 text-right" widget="new-messages">
<span> New messages </span>
<h2 class="font-bold"><?php
echo DataBase::query('SELECT COUNT(*) FROM messages WHERE opened = 0 AND recipient = ' . User::getID())->fetch()[0];
?>
</h2>
</div>
</div>
</div>
</div>
<!--<div class="col-lg-3">
<div class="ibox float-e-margins">
<div class="ibox-title">
<span class="label label-success pull-right">Monthly</span>
<h5>Income</h5>
</div>
<div class="ibox-content">
<h1 class="no-margins">40 886,200</h1>
<div class="stat-percent font-bold text-success">98% <i class="fa fa-bolt"></i></div>
示例12: foreach
//Verify if account exists
$haserror = true;
foreach ($accounts->get() as $acc) {
if ($_DATA['id'] == $acc['id']) {
$haserror = false;
$forProfileId = $acc['profile_id'];
break;
}
}
if ($haserror) {
RestUtils::sendResponse('406', array('data' => 'accountId', 'message' => 'A conta escolhida não existe.'));
exit;
}
if ($forProfileId != CurrentUser::getId()) {
RestUtils::sendResponse('406', array('data' => 'accountId', 'message' => 'A conta escolhida não pertence ao usuário.'));
exit;
}
//Disable STATUS
$sql->query("UPDATE accounts SET status = 0 WHERE id = '" . $_DATA['id'] . "'");
//Close Connection
$sql->close();
RestUtils::sendResponse('200');
exit;
break;
/////////////////////////////////////DEFAULT
/////////////////////////////////////DEFAULT
default:
RestUtils::sendResponse('405', array('message' => 'O método escolhido não é suportado.'));
exit;
break;
}
示例13: die
<?php
require 'framework/inc.php';
if (!isset($_GET['request'])) {
die('<h3>Bad request</h3>');
}
$req = $_GET['request'];
$ans = DataBase::query('SELECT ID, fullname FROM users WHERE fullname LIKE ' . DataBase::_secure('%' . $req . '%'));
$f = array();
while ($data = $ans->fetch()) {
$f[] = $data;
}
die(json_encode($f));
示例14: DataBase
function get_count($id)
{
$db = new DataBase();
$res = $db->query("select SUM(if(type = 'board',1,0)) as 'bcount', SUM(if(type = 'phone',1,0)) as 'pcount' from board_hits WHERE board_id = " . $id);
return mysql_fetch_array($res);
}
示例15: DataBase
$sql = new DataBase();
$sql->connect();
//Verify if exists
$tr = $transactions->get('all', '', '', '', $ID);
$data = $tr;
if (count($tr) == 0) {
RestUtils::sendResponse('406', array('data' => 'transactionId', 'message' => 'Essa transação não existe.'));
}
if ($tr[0]['profile_id'] != CurrentUser::getId()) {
RestUtils::sendResponse('406', array('data' => 'transactionId', 'message' => 'Essa transação não pertence ao perfil.'));
}
//Remove in Ammount
if ($data[0]['account_to'] != '') {
$balance = $accounts->get(1, $data[0]['account_from'], 'balance');
$balance += $data[0]['amount'];
$sql->query("UPDATE accounts SET balance='" . $balance . "' WHERE id = '" . $data[0]['account_from'] . "'");
$sql->query("UPDATE accounts_month_balance AS amb SET amb.balance = amb.balance + " . $data[0]['amount'] . " WHERE amb.account_id = '" . $data[0]['account_from'] . "' AND amb.year >= " . date('Y', strtotime($data[0]['date'])) . " AND amb.month >= " . date('n', strtotime($data[0]['date'])) . "");
$balance = $accounts->get(1, $data[0]['account_to'], 'balance');
$balance -= $data[0]['amount'];
$sql->query("UPDATE accounts SET balance='" . $balance . "' WHERE id = '" . $data[0]['account_to'] . "'");
$sql->query("UPDATE accounts_month_balance AS amb SET amb.balance = amb.balance - " . $data[0]['amount'] . " WHERE amb.account_id = '" . $data[0]['account_to'] . "' AND amb.year >= " . date('Y', strtotime($data[0]['date'])) . " AND amb.month >= " . date('n', strtotime($data[0]['date'])) . "");
} else {
$balance = $accounts->get(1, $data[0]['account_from'], 'balance');
$balance -= $data[0]['amount'];
$sql->query("UPDATE accounts SET balance='" . $balance . "' WHERE id = '" . $data[0]['account_from'] . "'");
$sql->query("UPDATE accounts_month_balance AS amb SET amb.balance = amb.balance - " . $data[0]['amount'] . " WHERE amb.account_id = '" . $data[0]['account_from'] . "' AND amb.year >= " . date('Y', strtotime($data[0]['date'])) . " AND amb.month >= " . date('n', strtotime($data[0]['date'])) . "");
}
//Remove
$sql->query("DELETE FROM transactions_has_tags WHERE transaction_id = '" . $ID . "'");
$sql->query("DELETE FROM transactions WHERE id = '" . $ID . "'");
//Close Connection