本文整理汇总了PHP中DB类的典型用法代码示例。如果您正苦于以下问题:PHP DB类的具体用法?PHP DB怎么用?PHP DB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DB类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: handler_updateLoginInfo
function handler_updateLoginInfo($redis, $channel, $msg)
{
helper_log("redis submsg: " . $msg);
$pubMsg = json_decode($msg, true);
$db = new DB();
$db->updateUser($pubMsg);
}
开发者ID:letmefly,项目名称:php_ramb,代码行数:7,代码来源:gamedata.php
示例2: update
public function update($data)
{
$db = new DB();
foreach ($data as $key => $value) {
$db->updateInTable($value, 'worker', $key);
}
}
开发者ID:shpikyliak,项目名称:kursach,代码行数:7,代码来源:ModelWorker.php
示例3: delete
public function delete($data)
{
$db = new DB();
for ($i = 0; $i < count($data); $i++) {
$db->delete($data[$i], 'style');
}
}
开发者ID:shpikyliak,项目名称:kursach,代码行数:7,代码来源:ModelStyle.php
示例4: insert
function insert()
{
$dbc = new DB();
$dbc->connect();
$sql = "insert into registered_users(FullName,Username,Password,Email,Mobile,RegNo) values('{$this->name}','{$this->username}','{$this->password}','{$this->email}','{$this->mobile}','{$this->regNo}')";
$dbc->query($sql);
}
开发者ID:adwalvekar,项目名称:iecse-app,代码行数:7,代码来源:register.php
示例5: getTopFive
function getTopFive($uid)
{
$db = new DB();
//Create an array of all companies in format [companyname => companyid]
$sql = "SELECT company_id, Name FROM Companies";
$compresults = $db->execute($sql);
$allcompanies = [];
$compavg = [];
while ($row = $compresults->fetch_assoc()) {
$allcompanies[$row['Name']] = $row['company_id'];
}
//Find the user's priority selection
$usrsql = "SELECT priority FROM People WHERE person_id = {$uid}";
$usrresults = $db->execute($usrsql);
$usrresults = $usrresults->fetch_assoc();
$priority = $usrresults['priority'];
//get the average rating of each company in the prioritized category and store in an array
foreach ($allcompanies as $key => $value) {
//hey guess what SQL can calculate column averages for you
$avgsql = "SELECT AVG({$priority}) FROM Reviews WHERE company_id = {$value}";
$avgresults = $db->execute($avgsql);
$avgresults = $avgresults->fetch_assoc();
$compavg[$key] = implode(".", $avgresults);
}
//sort finished array high to low and grab the top 5
arsort($compavg);
$topfive = array_slice($compavg, 0, 5);
return $topfive;
}
开发者ID:caityd1d,项目名称:team-synergy,代码行数:29,代码来源:top5.php
示例6: showCupones
function showCupones()
{
$database = new DB();
echo "\n <table class=\"table table-striped table-bordered bootstrap-datatable datatable\">\n <thead>\n\t\t\t<tr>\n <th> </th>\n\t\t\t <th>Cupon</th>\n\t\t\t <th>Compra Minima</th>\n\n\t\t\t <th>Tipo</th>\n\t\t\t <th>Opciones</th>\n\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>";
$query = "SELECT * from cupon,cupontipo\n where cupon.cupontipo_id=cupontipo.cupontipo_id";
$results = $database->get_results($query);
$i = 0;
foreach ($results as $row) {
$i += 1;
echo "<tr>\n\t\t\t <td align=right><font > {$i} </td>\n\t\t\t <td ><a href=\"/index.php?data=cupones&op=generados&bulk=" . $row['bulk'] . "\" >";
switch ($row['cupontipo_id']) {
case 1:
echo "\$ " . dinero($row['cantidad']) . " MX";
break;
case 2:
echo $row['cantidad'] . " %";
break;
}
echo "</b><a>\n\t\t\t </td>";
echo "<td><font >" . dinero($row['compra_minima']) . "</td>\n\n\t\t\t<td> <font >" . strtoupper($row['cupontipo']) . "</td>";
echo "<td><button class=\"btn-primary btn-setting hidden-print\" onclick=\"showData('myModal',\n 'view/cupones/cupones_agregar.inc.php',\n 'f=editar&cuid=" . $row['cupon_id'] . "')\">Editar</button>\n\n <button class=\"btn-info btn-setting hidden-print\" onclick=\"showData('myModal',\n 'view/cupones/cupones.php',\n 'f=generar&cuid=" . $row['cupon_id'] . "&cupon=" . $row['cupon'] . "&monto=" . $row['cantidad'] . "&compra_minima=" . $row['compra_minima'] . "')\">Generar</button></td>";
echo "</tr>";
}
echo " </tbody>\n </table>";
}
开发者ID:raulquintero,项目名称:speimx,代码行数:25,代码来源:cupones.src.php
示例7: getNombreUsuario
/**
* @desc Devuelve el nombre de un usuario
* @param int $id
* @return string
*/
function getNombreUsuario($id)
{
$db = new DB();
$sql = "SELECT CONCAT(nombres, ' ', apellidos) as nombre ";
$sql .= "FROM usuarios WHERE id = '{$id}'";
return $db->queryUniqueValue($sql);
}
开发者ID:peterweck,项目名称:catman,代码行数:12,代码来源:Utils.php
示例8: checkInstalled
function checkInstalled(DB $db, $config)
{
$db->Exec("CREATE TABLE IF NOT EXISTS `{$config['database']['prefix']}polls` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT,`question` text NOT NULL,`close_date` int(11) unsigned NOT NULL,`vote_repeating` smallint(5) unsigned NOT NULL,`cookie_expire` int(10) unsigned NOT NULL,`show_hide_results` smallint(5) unsigned NOT NULL,`order_results` tinyint(3) unsigned NOT NULL,`created` int(11) unsigned NOT NULL,`randomize_order` tinyint(1) unsigned NOT NULL,`closed` tinyint(1) unsigned NOT NULL,PRIMARY KEY (`id`))");
$db->Exec("CREATE TABLE IF NOT EXISTS `{$config['database']['prefix']}poll_answers` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT,`poll_id` int(10) unsigned NOT NULL,`answer` text NOT NULL,`sort_order` int(10) unsigned NOT NULL,`image` int(11) unsigned NOT NULL,PRIMARY KEY (`id`))");
$db->Exec("CREATE TABLE IF NOT EXISTS `{$config['database']['prefix']}poll_votes` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT,`poll_id` int(10) unsigned NOT NULL,`identifier` varchar(255) NOT NULL DEFAULT '',`voted_date` int(11) unsigned NOT NULL,`voted_ip` int(11) unsigned NOT NULL,`answer_id` int(11) unsigned NOT NULL,PRIMARY KEY (`id`))");
$db->Exec("CREATE TABLE IF NOT EXISTS `{$config['database']['prefix']}poll_images` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT,`upload_path` varchar(100) NOT NULL DEFAULT '',PRIMARY KEY (`id`))");
}
开发者ID:camargoanderso,项目名称:Simple-Poll-Engine,代码行数:7,代码来源:init.php
示例9: Save
public function Save()
{
if ($this->_POST) {
$ID = _intval($this->_POST['ID'], true);
$Data['Title'] = trim($this->_POST['Title']);
$Data['Url'] = trim($this->_POST['Url']);
$Data['Describe'] = trim($this->_POST['Describe']);
$Data['DisplayOrder'] = _intval($this->_POST['DisplayOrder'], true);
$Data['Property'] = _intval($this->_POST['Property'], true) ? 1 : 0;
$Data['Status'] = _intval($this->_POST['Status'], true) ? 1 : 0;
$Data['CategoryID'] = _intval($this->_POST['CategoryID'], true);
if (!$ID) {
$Data['Created'] = date('Y-m-d H:i:s', $this->timestamp);
$Data['CreatedUserID'] = $this->UserID;
} else {
$Data['Modified'] = date('Y-m-d H:i:s', $this->timestamp);
$Data['ModifiedUserID'] = $this->UserID;
}
$DB = new DB();
if ($ID) {
if ($DB->UpdateArray('tbl_links', $Data, array('ID' => $ID))) {
$this->__Message('修改友情链接成功!', UrlRewriteSimple('Links', 'Index', true), '继续操作');
} else {
$this->__Message('修改友情链接失败,请再一次尝试!');
}
} else {
if ($DB->insertArray('tbl_links', $Data)) {
$this->__Message('添加友情链接成功!', UrlRewriteSimple('Links', 'Index', true), '继续操作');
} else {
$this->__Message('添加友情链接失败,请再一次尝试!');
}
}
}
}
开发者ID:baiduXM,项目名称:agent,代码行数:34,代码来源:class.Links.php
示例10: queryDB
function queryDB($args, $query, $bindings = null)
{
$results = [];
try {
$DB = new DB();
$offset = 0;
$limit = 25;
if (isset($args["offset"])) {
$offset = abs(intval($args["offset"]));
}
if (isset($args["limit"])) {
$limit = abs(intval($args["limit"]));
}
if (strpos($query, 'select') !== false) {
$query .= " limit " . $limit . " offset " . $offset;
}
$query .= ";";
$queryOut = $DB->query($query, $bindings);
$results["data"] = $queryOut;
$results["meta"]["ok"] = true;
$results["debug"]["offset"] = $offset;
$results["debug"]["limit"] = $limit;
$results["debug"]["count"] = count($queryOut);
} catch (Exception $e) {
error_log($e);
$results["meta"]["ok"] = false;
$results["debug"]["dbException"] = $e->getMessage();
}
$results["debug"]["query"] = $query;
$results["debug"]["bindings"] = $bindings;
return $results;
}
开发者ID:GeekyAubergine,项目名称:chrisaubert.co.uk,代码行数:32,代码来源:io.php
示例11: mostrar_transacciones
function mostrar_transacciones($fecha_inicio, $fecha_fin, $user)
{
$database = new DB();
//$fecha=fechaplusweek($fecha);
$total_pagos = ceil($total / $abono);
echo "\n\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<table class=\"table table-condensed striped\" width=100% >\n\t\t\t\t\t\t\t <thead>\n\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t <th style='text-align:right'>Id</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Fecha</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Movimiento</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Total</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Cliente</th>\n\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t </thead>\n\t\t\t\t\t\t\t <tbody>";
$fecha_inicio_bd = $fecha_inicio;
$fecha_fin_bd = $fecha_fin;
$query = "SELECT * from movimiento,tipomov,admin,cliente\n\t\twhere movimiento.tipomov_id=tipomov.tipomov_id AND movimiento.admin_id=admin.admin_id AND (movimiento.tipomov_id=1 OR movimiento.tipomov_id=13 or movimiento.tipomov_id=14)\n AND movimiento.cliente_id=cliente.cliente_id AND cliente.empresa_id=0";
if ($fecha_inicio) {
$query .= " AND fecha>='{$fecha_inicio_bd}' AND fecha<='{$fecha_fin_bd} 23:59:59' ";
}
if ($user) {
$query .= " AND movimiento.admin_id={$user} ";
}
$query .= " ORDER BY fecha DESC";
$results = $database->get_results($query);
foreach ($results as $item) {
$vendedor = $item['nombre'] . " " . $item['apellidop'];
echo "<tr><td style='text-align:right' width=30 >" . $item['movimiento_id'] . "</td>\n\t\t\t\t\t\t<td style='text-align:center'><span class='hidden-desktop'>" . fechamysqltous($item['fecha']) . "</span><a class='hidden-print' href=/index.php?data=estadisticas&op=ventas&fi=" . fechamysqltous($fecha_inicio) . "&hi={$hi}&ff=" . fechamysqltous($fecha_fin) . "&hf={$hf}&fid=" . $item['factura_id'] . ">" . fechamysqltomx($item['fecha'], "letra") . "</a></td>\n\t\t\t\t\t\t\t<td style='text-align:center'>" . $item['tipomov'] . "\n\t\t\t\t\t\t\t<br></td>\n\t\t\t\t\t\t\t<td style='text-align:right'>\$ " . dinero($item['cantidad'] + $item['iva']) . "</td>\n\t\t\t\t\t\t\t<td style='text-align:right'>" . $vendedor;
echo " </td></tr>";
$n++;
}
echo " </tbody>\n\t\t</table> ";
//echo "Pagos Atrazados: ".$pagos_atrazados;
echo "</div>";
}
开发者ID:raulquintero,项目名称:speimx,代码行数:27,代码来源:pos_cortedecaja.php
示例12: results
public function results()
{
$this->queryBuilder();
$db = new DB();
$this->results = $db->query($this->sql_builder)->fetch_all()->resultArray;
return $this->results;
}
开发者ID:virutmath,项目名称:crm_local,代码行数:7,代码来源:DBTable.php
示例13: login
public function login($login, $pass)
{
//echo "construct " . $this->name[0];
if (!isset($_COOKIE['auth'])) {
$db = new DB();
$sql = "SELECT *\n FROM users\n WHERE username = '" . $login . "'";
$result = $db->query($sql);
if ($row = $db->fetch_array($result)) {
if ($row['password'] == md5($pass)) {
$this->name = $login;
$this->id = $row['id'];
setcookie('user_id', $row['id']);
setcookie('auth', md5(time()));
setcookie('name', $this->name);
} else {
die('error login');
}
} else {
die('login error');
}
} else {
$this->name = $_COOKIE['name'];
$this->id = $_COOKIE['user_id'];
}
return $this->name;
}
开发者ID:hawk56,项目名称:websocket,代码行数:26,代码来源:Auth.php
示例14: updateMovie
public function updateMovie($uid, $imdbid, $catid = array())
{
$db = new DB();
$catid = !empty($catid) ? $db->escapeString(implode('|', $catid)) : "null";
$sql = sprintf("update usermovies set categoryID = %s where userID = %d and imdbID = %d", $catid, $uid, $imdbid);
$db->query($sql);
}
开发者ID:ehsanguru,项目名称:nnplus,代码行数:7,代码来源:usermovies.php
示例15: insert
function insert()
{
$db = new DB();
$db->connect();
$sql = "insert into contact(Username,Comments) values('{$this->username}','{$this->comments}')";
$db->query($sql);
}
开发者ID:adwalvekar,项目名称:iecse-app,代码行数:7,代码来源:contact.php
示例16: login
public function login($POST)
{
$db = new DB();
$user = new User();
$user->setEmail($POST["email"]);
$user->setPassword($POST["password"]);
if ($user->getEmail() == "") {
$response["status"] = 1;
$response["msg"] = "กรุณากรอก Email";
} else {
if ($user->getPassword() == "") {
$response["status"] = 2;
$response["msg"] = "กรุณากรอก Password";
} else {
$array = array("email" => array("type" => $user->getDataType("email"), "value" => $user->getEmail()), array("type" => $user->getDataType("password"), "value" => $user->getPassword()));
$sql = "SELECT * FROM users WHERE email = ? AND password = ?";
$data = $db->query($sql, $array);
if (count($data) > 0) {
$response["status"] = 0;
$response["msg"] = "Success";
} else {
$response["status"] = -1;
$response["msg"] = "ไม่พบ Email/Password นี้ในระบบ";
}
}
}
echo json_encode($response);
}
开发者ID:Wasan45,项目名称:PDCA_Project-Service-,代码行数:28,代码来源:UserController.php
示例17: get_thumb
function get_thumb($id_imagen, $height, $width)
{
$cnx = new DB();
$sql = "SELECT vin_imagen FROM vinculacion WHERE vin_id='" . $id_imagen . "'";
$registro = $cnx->get_registro($sql);
$image_path = "../../sistema/images/vinculacion/" . $registro->vin_imagen;
//debug($image_path);exit();
// $image_path = "../../sistema/images/vinculacion/1.png";
/*
$arreglo = array("images","no_disponible.jpg");//Si el archivo no existe
if(file_exists("../".$imagen))
{
$arreglo = explode("/",$imagen);
}
else
{
$imagen = implode ("/",$arreglo);
}
*/
$images = new Imagenes();
$images->set_height($height);
$images->set_width($width);
$images->set_path_file($image_path);
return $images->get_thumb();
}
开发者ID:etlapa,项目名称:uiest,代码行数:26,代码来源:class.vinculacion.php
示例18: viewTransactions
function viewTransactions()
{
$db = new DB();
$stmt = $db->query("SELECT a.ID, a.amount, a.user_ID, b.name, a.type, c._type, a.date_trans, a.notes, \n\t\t\t\t\tCASE a.status\n\t\t\t\t\t\tWHEN 0 THEN 'On Process'\n\t\t\t\t\t\tWHEN 1 THEN 'Complete'\n\t\t\t\t\tEND as `status`\n\t\t\t\t\tFROM transactions AS a, users AS b, `user-meta` AS c\n\t\t\t\t\tWHERE a.user_ID = b.ID AND c.user_ID = b.ID AND a.user_ID = " . $_SESSION['user_ID'] . " ORDER BY a.ID DESC", array());
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
return empty($result) ? false : $result;
}
开发者ID:etuyco,项目名称:v2.inlight-marketing,代码行数:7,代码来源:transaction.php
示例19: save
public function save($isNewUser = false)
{
//create a new database object.
$db = new DB();
$username = mysql_real_escape_string($this->username);
$email = mysql_real_escape_string($this->email);
$firstName = mysql_real_escape_string($this->firstName);
$lastName = mysql_real_escape_string($this->lastName);
$link = mysql_real_escape_string($this->link);
$blog = mysql_real_escape_string($this->blog);
//if the user is already registered and we're
//just updating their info.
if (!$isNewUser) {
//set the data array
$data = array("username" => "'{$username}'", "password" => "'{$this->hashedPassword}'", "email" => "'{$email}'", "firstName" => "'{$firstName}'", "lastName" => "'{$lastName}'", "link" => "'{$link}'", "blog" => "'{$blog}'");
//update the row in the database
$db->update($data, 'users', 'id = ' . $this->id);
} else {
//if the user is being registered for the first time.
$data = array("username" => "'{$username}'", "password" => "'{$this->hashedPassword}'", "email" => "'{$email}'", "link" => "'{$link}'", "blog" => "'{$blog}'", "firstName" => "'{$firstName}'", "lastName" => "'{$lastName}'", "join_date" => "'" . date("Y-m-d H:i:s", time()) . "'");
$this->id = $db->insert($data, 'users');
$this->joinDate = time();
}
return true;
}
开发者ID:OniGen1337,项目名称:Commentz,代码行数:25,代码来源:User.class.php
示例20: testInstall
public function testInstall()
{
global $DB;
$query = "SHOW FULL TABLES WHERE TABLE_TYPE LIKE 'VIEW'";
$result = $DB->query($query);
while ($data = $DB->fetch_array($result)) {
$DB->query("DROP VIEW " . $data[0]);
}
$query = "SHOW TABLES";
$result = $DB->query($query);
while ($data = $DB->fetch_array($result)) {
$DB->query("DROP TABLE " . $data[0]);
}
include_once GLPI_ROOT . "/inc/dbmysql.class.php";
include_once GLPI_CONFIG_DIR . "/config_db.php";
// Install a fresh 0.80.5 DB
$DB = new DB();
$res = $DB->runFile(GLPI_ROOT . "/install/mysql/glpi-0.80.3-empty.sql");
$this->assertTrue($res, "Fail: SQL Error during install");
// update default language
$query = "UPDATE `glpi_configs`\n SET `language` = 'en_GB'";
$this->assertTrue($DB->query($query), "Fail: can't set default language");
$query = "UPDATE `glpi_users`\n SET `language` = 'en_GB'";
$this->assertTrue($DB->query($query), "Fail: can't set users language");
$GLPIlog = new GLPIlogs();
$GLPIlog->testSQLlogs();
$GLPIlog->testPHPlogs();
}
开发者ID:RubichonL,项目名称:glpi_monitoring,代码行数:28,代码来源:AllTests.php
注:本文中的DB类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论