当前位置: 首页>>代码示例>>PHP>>正文


PHP DB类代码示例

本文整理汇总了PHP中DB的典型用法代码示例。如果您正苦于以下问题:PHP DB类的具体用法?PHP DB怎么用?PHP DB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>&nbsp;</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 >&nbsp;{$i}&nbsp;</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 "&nbsp;&nbsp;</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


注:本文中的DB类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。