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


PHP db类代码示例

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


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


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