• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP db类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了db类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: buildQuery

 function buildQuery()
 {
     // check if query is set
     if (empty($this->query)) {
         $this->error = ' NO QUERY SET ';
         $this->rQuery = false;
     }
     // check the mysql object
     if (!is_a($this->mysqlOBJ, 'mysql')) {
         $this->error = ' NO MYSQL OBJECT SET ';
         $this->rQuery = false;
     }
     // check the numbers of pages
     $objDb = new db();
     //echo $this->query ;
     //echo "<br>";
     $this->result = $objDb->ExecuteQuery($this->query);
     $this->totalRows = mysql_num_rows($this->result);
     if ($this->result !== false) {
         //$this->totalRows=$this->mysqlOBJ->num_rows;
         $this->totalPages = ceil($this->totalRows / $this->maxpage);
     } else {
         $this->error = ' ERROR EXECUTING QUERY ';
         $this->rQuery = false;
     }
     //echo "<br>";
     //echo $this->totalPages ;
     if ($this->totalRows <= $this->maxpage) {
         $this->rQuery = $this->query;
     } else {
         $this->cPage = $this->cPage <= $this->totalPages ? $this->cPage : '1';
         $limit = " LIMIT " . ($this->cPage - 1) * $this->maxpage . "," . $this->maxpage;
         $this->rQuery = $this->query . $limit;
     }
 }
开发者ID:beyondkeysystem,项目名称:testone,代码行数:35,代码来源:pagination.php


示例2: authenticate

    function authenticate($U, $P, $recordar = 0, $by = 'usuario')
    {
        $RESULT = false;
        if (trim($U) != '' && trim($P) != '') {
            $db = new db();
            $db->connect();
            $sql = ' SELECT * FROM usuarios
						 WHERE ( ' . $by . ' = "' . mysql_real_escape_string($U) . '" )
						 AND   ( password = "' . md5($P) . '" )
						 ';
            $db->query($sql);
            // no existe
            $RESULT = false;
            while ($record = $db->next()) {
                // LOGEAR
                $this->creaSession($record);
                $RESULT = true;
                if ($recordar) {
                    $two_months = time() + 30 * 24 * 3600;
                    setcookie('id_usuario', $U, $two_months);
                    setcookie('contrasena', $P, $two_months);
                }
            }
            $db->close();
        }
        return $RESULT;
    }
开发者ID:mtaisigue,项目名称:albaranes,代码行数:27,代码来源:Login.php


示例3: login2

function login2($user, $pass)
{
    $con = new db();
    $conc = $con->c();
    $kcook = intval($_POST["remember"]);
    $q = mysqli_query($conc, "SELECT `id`,`user`,`name`,`email`,`img1`,`img2`,`img3`,`bgcolor` FROM `users` WHERE (`user` = '{$user}' OR `email` ='{$user}') AND pass = '{$pass}'");
    if (mysqli_num_rows($q) == 1) {
        $r = mysqli_fetch_array($q);
        setcookie("u", $r[1], time() + 52 * 60 * 60 * 24 * 7, "/");
        $_SESSION["uid"] = $r[0];
        $_SESSION["user"] = $r[1];
        $_SESSION["name"] = $r[2];
        $_SESSION["email"] = $r[3];
        $_SESSION["p"] = $pass;
        $_SESSION["color"] = $r[7];
        $_SESSION["img1"] = $r[4];
        $_SESSION["img2"] = $r[5];
        $_SESSION["img3"] = $r[6];
        $_SESSION["ula"] = md5("{$r['1']} {$pass} {$r['0']}");
        $con->close_db_con($conc);
        if (!valid_name($_SESSION["user"])) {
            $_SESSION["set_user"] = "Please correct your username remove symbols, characters or spaces, and should be less than 20 characters";
            header("location: ./?settings");
        } else {
            if ($kcook == 1) {
                setcookie("um", $r[1], time() + 52 * 60 * 60 * 24 * 7, "/");
                setcookie("pm", $pass, time() + 52 * 60 * 60 * 24 * 7, "/");
            }
            return true;
        }
    } else {
        return false;
    }
}
开发者ID:gottsohn,项目名称:muzikkitchen,代码行数:34,代码来源:index.php


示例4: add_youtube_video

function add_youtube_video()
{
    global $config;
    require_once $config["path_to_default_site_module"] . "/models/db.php";
    require_once $config["path_to_default_site_module"] . "/models/video.php";
    $ch = curl_init("https://gdata.youtube.com/feeds/api/videos/-/preachcaster?alt=json");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $json_string_data = curl_exec($ch);
    curl_close($ch);
    $video_data = json_decode($json_string_data, true);
    $db_conn = new db($config["db_connection"]);
    $db_resource = $db_conn->get_resource();
    $video = new Video($db_resource);
    foreach ($video_data["feed"]["entry"] as $single_video) {
        //parse out ID
        $tmp_array = explode("/", $single_video["id"]['$t']);
        $video_id = $tmp_array[count($tmp_array) - 1];
        //rxBS1E0KZQU
        //CQzUsTFqtW0
        $video_params = array("video_id" => $video_id, "author" => $single_video["author"][0]["name"]['$t'], "title" => $single_video["title"]['$t'], "description" => $single_video["content"]['$t'], "date_recorded" => isset($single_video['yt$recorded']) ? $single_video['yt$recorded']['$t'] : null, "location" => isset($single_video['yt$location']) ? $single_video['yt$location']['$t'] : null, "url" => isset($single_video['media$group']['media$player']) ? $single_video['media$group']['media$player'][0]["url"] : null, "duration" => isset($single_video['media$group']['yt$duration']) ? $single_video['media$group']['yt$duration']["seconds"] : null, "comment_url" => isset($single_video['gd$comments']) && isset($single_video['gd$comments']['gd$feedLink']) ? $single_video['gd$comments']['gd$feedLink']["href"] : null, "thumbnails" => isset($single_video['media$group']) && isset($single_video['media$group']['media$thumbnail']) ? $single_video['media$group']['media$thumbnail'] : null);
        $video->add_video($video_params, "YouTube");
    }
    die("here");
}
开发者ID:natestarner,项目名称:preachcaster,代码行数:25,代码来源:add_youtube_video.php


示例5: getEventById

function getEventById($id)
{
    $db = new db(EZSQL_DB_USER, EZSQL_DB_PASSWORD, EZSQL_DB_NAME, EZSQL_DB_HOST);
    $evVal = $db->get_row("select * from events where event_id=" . $id);
    $ev = getEventFromTable($evVal);
    return $ev;
}
开发者ID:rupeshmore85,项目名称:dwa,代码行数:7,代码来源:common.php


示例6: snippetsOptions

function snippetsOptions()
{
    $db = new db();
    $log = ADLog::getInstance();
    /*
     * Extract all snippets for select list below
     */
    $q = "SELECT id, snippetName\n\t\t\t\t\t\tFROM snippets \n\t\t\t\t\t\tORDER BY snippetName ASC";
    $result = $db->q($q);
    $num_rows = mysql_numrows($result);
    if (!$result || $num_rows < 0) {
        $log->Warn("Failure: Problem Displaying snippetsOptions() options (File: " . $_SERVER['PHP_SELF'] . ")");
        echo "Error displaying info for reportsOptions() function";
        return;
    }
    if ($num_rows == 0) {
        $log->Warn("Failure: Problem Displaying snippetsOptions() - no options returned (File: " . $_SERVER['PHP_SELF'] . ")");
        echo "Database table empty";
        return;
    }
    for ($i = 0; $i < $num_rows; $i++) {
        $id = mysql_result($result, $i, "id");
        $snippetName = mysql_result($result, $i, "snippetName");
        echo "<option value=snippetId-" . $id . ">" . $snippetName . "</option>";
    }
}
开发者ID:3tan,项目名称:rconfig,代码行数:26,代码来源:scheduler.frm.func.php


示例7: AuthFuncCheckUserSignup

function AuthFuncCheckUserSignup($username, $password)
{
    $password = UtilFuncEncryptUserPassword($password);
    $db = new db();
    $userid = $db->Ins('user', array('username' => $username, 'password' => $password));
    return @$userid;
}
开发者ID:BGCX261,项目名称:zjxt-svn-to-git,代码行数:7,代码来源:authorization.func.php


示例8: render

 function render($layout, $array, $output = "backend")
 {
     if ($output == "backend") {
         $extensions = new extensions();
         $active = explode('/', $_SERVER['REQUEST_URI']);
         $activeDupe = $active;
         $active = isset($active[2]) ? $active[2] : false;
         if (strpos($active, "?") !== false) {
             $active = explode('?', $active)[0];
         }
         if ($active == "extension") {
             $active = isset($activeDupe[3]) ? $activeDupe[3] : $active;
         }
         $array['activePage'] = strtolower($active);
         $array['extensions'] = $extensions->listAll(false);
         echo $this->backend->render("component/" . $layout . ".twig", $array);
     } else {
         $db = new db("variables");
         $config = new config();
         $array['config'] = $config->system->evany;
         $array['variables'] = $db->all();
         if (strpos($layout, ".twig") !== FALSE) {
             $layout = $layout;
         } else {
             $layout = $layout . ".twig";
         }
         return $this->frontend->render($layout, $array);
     }
 }
开发者ID:jakerb,项目名称:Tucan-CMS,代码行数:29,代码来源:twig.php


示例9: return_response

 /**
  * Method to return the status of the AJAX transaction
  *
  * @return  string A string of raw HTML fetched from the Server
  */
 function return_response()
 {
     $db = new db(EZSQL_DB_USER, EZSQL_DB_PASSWORD, EZSQL_DB_NAME, EZSQL_DB_HOST);
     //$queryVars = sanitize($queryVars);
     $sTimeStr = $this->queryVars['st'];
     $eTimeStr = $this->queryVars['et'];
     $evName = $this->queryVars['eventName'];
     // Sanitize event name
     $evName = filter_var($evName, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $desc = $this->queryVars['desc'];
     // Sanitize event description
     $desc = filter_var($desc, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $allDayIndicator = $this->queryVars['allDay'];
     $groupId = $this->queryVars['groupId'];
     $db->query("insert into events(event_name,event_description, calendar_id, all_day, start_time, end_time) VALUES ('" . $evName . "', '" . $desc . "', '" . $groupId . "', " . $allDayIndicator . ",  '" . $sTimeStr . "', '" . $eTimeStr . "')");
     $input = array();
     $input['eventName'] = $evName;
     $input['eventDesc'] = $desc;
     $input['group']['groupId'] = $groupId;
     if ($allDayIndicator == 0) {
         $input['allDay'] = false;
     } else {
         $input['allDay'] = true;
     }
     $input['eventId'] = $db->insertedId;
     $input['startTime'] = $sTimeStr;
     $input['endTime'] = $eTimeStr;
     return $input;
 }
开发者ID:rupeshmore85,项目名称:dwa,代码行数:34,代码来源:createevent.php


示例10: SupprimerUtilisateur

 public function SupprimerUtilisateur($id)
 {
     $rq = "DELETE FROM " . SCHEMA . ".UTILISATEURS_OSI WHERE ID=" . $id;
     $SCHEMA = new db();
     $SCHEMA->db_connect();
     $SCHEMA->db_query($rq);
 }
开发者ID:anisinfo,项目名称:osi,代码行数:7,代码来源:Utilisateurs.php


示例11: doLogin

function doLogin($usu_login, $usu_senha)
{
    $db = new db("../config.php");
    $json = new Services_JSON();
    $db->executa($db->getJoinRecord("funcionarios", "fun_nome='{$usu_login}' and fun_senha='{$usu_senha}'", '', 0), true, "user");
    if ($db->num_rows == 1) {
        $id = $db->user["usu_id"];
        $login = $db->user["usu_login"];
        $itens = array("usu_id" => $id, "usu_login" => $login, "status" => 1);
        $str = $json->encode($itens);
        session_register("usu_nome");
        session_register("usu_id");
        $_SESSION["usu_modulo"] = 0;
        $_SESSION["usu_nome"] = $db->user["fun_nome"];
        $_SESSION["usu_id"] = $db->user["fun_id"];
        $_SESSION["sis_exerc"] = $exercicio;
        $_SESSION["usu_grpid"] = $grp_id;
        $_SESSION["bgcolor"] = "#EAE5DA";
        $_SESSION["dtatend"] = date("d/m/Y");
        if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
            $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
        } else {
            $ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
        }
    } else {
        $itens = array("usu_id" => '', "usu_login" => $_GET["usu_login"], "status" => 2);
        $str = $json->encode($itens);
    }
    return $str;
}
开发者ID:tavo1981,项目名称:phpbar,代码行数:30,代码来源:fc_login.php


示例12: testGetUserById

 public function testGetUserById()
 {
     print_r($this->db->getUserById(1));
     $id = 1;
     $this->assertFalse($this->db->getUserById(99));
     $this->assertEquals('Andrew', $this->db->getUserById(1));
 }
开发者ID:astonecipher,项目名称:Automotive-CMS,代码行数:7,代码来源:dbTest.php


示例13: add

 function add($postArray)
 {
     if (User::isAdmin()) {
         $bm = BandMember::get($postArray['member_id']);
     } else {
         $uo = User::getCurrent();
         $bm = BandMember::getByUserID($uo->getID());
     }
     if (db::isError($bm)) {
         return $bm;
     }
     $db = new db();
     $member_id = $bm->getID();
     $title = $db->sanitize_to_db($postArray['title']);
     $_dt = strtotime($postArray['date']);
     $dt = date('Y-m-d', $_dt) . ' ' . $postArray['time'];
     $dateTime = date("Y-m-d H:i:s", strtotime($dt));
     $body = $db->sanitize_to_db($postArray['body']);
     if (!$title) {
         $title = '(untitled)';
     }
     $r = @mysql_query("insert into Band_Diaries (title, member_id, date_time, body, is_active) values ('{$title}','{$member_id}','{$dateTime}','{$body}'," . DEFAULT_ACTIVE . ")");
     if (!$r) {
         return Error::MySQL();
     } else {
         $bd = BandMemberDiary::get(mysql_insert_id());
         return $bd;
     }
 }
开发者ID:pinecreativelabs,项目名称:audition,代码行数:29,代码来源:band_diaries.php


示例14: return_response

 /**
  * Method to return the status of the AJAX transaction
  *
  * @return  string A string of raw HTML fetched from the Server
  */
 function return_response()
 {
     $db = new db(EZSQL_DB_USER, EZSQL_DB_PASSWORD, EZSQL_DB_NAME, EZSQL_DB_HOST);
     $allday = $this->queryVars['allDay'];
     $sTime = $this->queryVars['st'];
     $eTime = $this->queryVars['et'];
     $evName = $this->queryVars['eventName'];
     // Sanitize event name
     $evName = filter_var($evName, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $desc = $this->queryVars['desc'];
     // Sanitize event description
     $desc = filter_var($desc, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
     $allDayIndicator = $this->queryVars['allDay'];
     $eventId = $this->queryVars['eventId'];
     $groupId = $this->queryVars['groupId'];
     $input = array();
     $input['eventId'] = $eventId;
     $input['startTime'] = $sTime;
     $input['endTime'] = $eTime;
     $input['allDay'] = $allday == 1 ? true : false;
     $input['group']['groupId'] = $groupId;
     $input['eventId'] = $eventId;
     //echo ($sTime."===".$eTime."update  events set start_time='".$sTime."',  end_time='".$eTime."', event_name='".$evName."',event_description='".$desc."', calendar_id='".$groupId."', all_day='".$allDayIndicator."'  where event_id=".$eventId);
     $db->query("update events set start_time='" . $sTime . "',  end_time='" . $eTime . "', event_name='" . $evName . "',event_description='" . $desc . "', calendar_id='" . $groupId . "', all_day='" . $allDayIndicator . "'  where event_id=" . $eventId);
     $input['eventName'] = $evName;
     $input['eventDesc'] = $desc;
     return $input;
 }
开发者ID:rupeshmore85,项目名称:dwa,代码行数:33,代码来源:updateeventfull.php


示例15: handle

 function handle()
 {
     //$storage = new JingdongStorageService(accesskey, secrectkey);
     /*
     $fileName = uniqid().'.mobi';
     $filePath = 'tmp/' + $fileName;
     $fp = fopen($filePath, 'wb+');
     
     
     if($fp){
     	        	$storage->get_object(bookbucket,$this->bid,$fp, false);
     	        	
     }
     else
     	echo 'error';
     */
     $filePath = './jae/' . $this->bid;
     if (!file_exists($filePath)) {
         download($this->bid);
     }
     $fp = fopen($filePath, 'r');
     Header("Content-type: application/octet-stream");
     Header("Accept-Ranges: bytes");
     Header("Accept-Length: " . filesize($filePath));
     Header("Content-Disposition: attachment; filename=" . $this->bid);
     echo fread($fp, filesize($filePath));
     fclose($fp);
     if (isset($_SESSION['email'])) {
         $email = $_SESSION['email'];
         $db = new db();
         $db->addDownload($email, $this->bid, '下载', '成功');
     }
 }
开发者ID:andy-sheng,项目名称:ebook,代码行数:33,代码来源:DownloadController.class.php


示例16: SelectAppliSearch

 public function SelectAppliSearch($name, $enseigne, $irt, $trigramme)
 {
     $tabParam = array();
     if ($name) {
         $tabParam['libelle'] = $name;
     }
     if ($enseigne) {
         $tabParam['enseigne'] = $enseigne;
     }
     if ($irt) {
         $tabParam['irt'] = $irt;
     }
     if ($trigramme) {
         $tabParam['trigramme'] = $trigramme;
     }
     $rq = "SELECT ID,LIBELLE,ENSEIGNE,IRT,TRIGRAMME  FROM " . SCHEMA . ".APPLICATION ";
     $rq .= "WHERE ";
     $l = 1;
     foreach ($tabParam as $key => $value) {
         $or = $l != count($tabParam) ? " AND" : "";
         $rq .= "UPPER(REPLACE({$key},' ','')) LIKE '%" . strtoupper(str_replace(' ', '', $value)) . "%' " . $or;
         $l++;
     }
     $rq .= " ORDER BY NAME";
     $db = new db();
     $db->db_connect();
     $db->db_query($rq);
     $res = $db->db_fetch_array();
     return $res;
 }
开发者ID:anisinfo,项目名称:osi,代码行数:30,代码来源:Application.php


示例17: install

    private function install()
    {
        global $db_config;
        if (is_array($db_config)) {
            redirect("/");
        }
        $param['writable'] = file_put_contents(APP . 'writable.tmp', 'test');
        if (isset($_POST['db_type'])) {
            $db_type = $_POST['db_type'] == 'sqlite' ? 'sqlite' : 'mysql';
            $_POST['default_db'] = $db_type == 'sqlite' ? rand(100000, 999999) . '.sqlite' : $_POST['default_db'];
            //     $cname = 'db_'.$db_type;
            $db = new db($_POST);
            $sql = file_get_contents(APP . $db_type . '_ins.sql');
            $db->muti_query($sql);
            $base_dir = rtrim($_POST['base_dir'], '/') . '/';
            $seed = randstr();
            file_put_contents(APP . 'config_user.php', '<?
define(\'BASE\',\'?/\');
define(\'SEED\',\'' . $seed . '\');
$db_config = array(
  \'host\'      =>\'' . $_POST['host'] . '\', 
  \'user\'      =>\'' . $_POST['user'] . '\',  
  \'password\'  =>\'' . $_POST['password'] . '\', 
  \'db_type\'   =>\'' . $_POST['db_type'] . '\',
  \'default_db\'=>\'' . $_POST['default_db'] . '\'
);');
            redirect($_POST['base_dir'], '安装成功', '用户名 [email protected] 密码 admin', '8');
        } else {
            header("Content-type: text/html; charset=utf-8");
            $base = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']);
            view("v/home/install", $param);
        }
    }
开发者ID:grewumi,项目名称:erp.jianqu.org,代码行数:33,代码来源:__construct.php


示例18: username

function username($id)
{
    $username = new db();
    $username->query("select name from accounts where id = '{$id}'");
    $username->fetch();
    return $username->element("name");
}
开发者ID:awei0905,项目名称:Elimination-Series,代码行数:7,代码来源:mysql.php


示例19: test_quitar_item

 function test_quitar_item()
 {
     $compra = new compras();
     $db1 = new db();
     $resultado = $db1->consulta(7);
     $this->assertEquals($resultado - 1, $compra->quitar_inventario(7));
 }
开发者ID:analisis1G22015,项目名称:F4,代码行数:7,代码来源:compras_test_quitar_item.php


示例20: first_login

function first_login($userid)
{
    $db = new db();
    $query = $db->query("SELECT first_login from users WHERE user_id = '{$userid}'");
    $row = $query->fetch_array();
    return $row[0] == 0;
}
开发者ID:Kaarel94,项目名称:Veebirakenduste-loomine,代码行数:7,代码来源:users.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP dbConnect类代码示例发布时间:2022-05-23
下一篇:
PHP datos类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap