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


PHP db::prepare方法代码示例

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


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

示例1: __construct

 public function __construct($ID)
 {
     $query = db::prepare("SELECT * FROM passenger WHERE id=?");
     $query->bindValue(1, $ID);
     try {
         $query->execute();
     } catch (PDOException $e) {
         die($e->getMessage());
     }
     $passengerInfo = $query->fetchAll();
     $this->id = $passengerInfo[0][0];
     $this->prefix = $passengerInfo[0][1];
     $this->first_name = $passengerInfo[0][2];
     $this->last_name = $passengerInfo[0][3];
     $this->middle_name = $passengerInfo[0][4];
     $this->suffix = $passengerInfo[0][5];
     $this->date_of_birth = $passengerInfo[0][6];
     $this->gender = $passengerInfo[0][7];
     $this->emergency_contact_phone = $passengerInfo[0][8];
     $this->emergency_contact_country = $passengerInfo[0][9];
     $this->emergency_contact_first_name = $passengerInfo[0][10];
     $this->emergency_contact_last_name = $passengerInfo[0][11];
     $this->date_added = $userInfo[0][12];
     $this->date_updated = $userInfo[0][13];
 }
开发者ID:simonwoosh,项目名称:cs290,代码行数:25,代码来源:passenger.php

示例2: OS_UpdateScoresTable

function OS_UpdateScoresTable($name = "")
{
    $db = new db("mysql:host=" . OSDB_SERVER . ";dbname=" . OSDB_DATABASE . "", OSDB_USERNAME, OSDB_PASSWORD);
    $name = safeEscape(trim($name));
    if (!empty($name)) {
        $sth = $db->prepare("SELECT * FROM scores WHERE (name) = ('" . $name . "')");
        $result = $sth->execute();
        if ($limit = $sth->rowCount() <= 0) {
            $sth = $db->prepare("INSERT INTO scores(category, name)VALUES('dota_elo','" . $name . "')");
            $result = $sth->execute();
        }
        //Get updated result
        $resultScore = $db->prepare("SELECT player,score FROM " . OSDB_STATS . " WHERE (player) = ('" . $name . "')");
        $result = $resultScore->execute();
        $rScore = $resultScore->fetch(PDO::FETCH_ASSOC);
        //update "scores" table
        $UpdateScoreTable = $db->prepare("UPDATE `scores` SET `score` = '" . $rScore["score"] . "' \n\tWHERE (name) = ('" . $rScore["player"] . "') ");
        $result = $UpdateScoreTable->execute();
    }
}
开发者ID:WeKiNGSRO,项目名称:OHSystem,代码行数:20,代码来源:cron_DEPRECATED.php

示例3: delete

 public static function delete($id)
 {
     $query = db::prepare("DELETE FROM order WHERE id=?");
     $query->bindValue(1, $id);
     try {
         $query->execute();
         return True;
     } catch (PDOException $e) {
         die($e->getMessage());
     }
 }
开发者ID:simonwoosh,项目名称:cs290,代码行数:11,代码来源:orders.php

示例4: UpdateCommentsByPostIds

function UpdateCommentsByPostIds($PostIDS = '')
{
    $db = new db("mysql:host=" . OSDB_SERVER . ";dbname=" . OSDB_DATABASE . "", OSDB_USERNAME, OSDB_PASSWORD);
    $sth = $db->prepare("SET NAMES 'utf8'");
    $result = $sth->execute();
    //Prepare query and update total comments for each post
    $query = "SELECT * FROM " . OSDB_NEWS . " WHERE ";
    $PIDS = explode(",", $PostIDS);
    for ($i = 0; $i < count($PIDS); $i++) {
        $query .= " news_id = '" . $PIDS[$i] . "' OR";
    }
    $query = substr($query, 0, -3);
    $sth = $db->prepare($query);
    $result = $sth->execute();
    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
        //echo $row["post_id"]. " | ";
        $get = $db->prepare("SELECT COUNT(*) FROM " . OSDB_COMMENTS . " WHERE post_id= '" . $row["news_id"] . "' LIMIT 1");
        $result = $get->execute();
        $r = $get->fetch(PDO::FETCH_NUM);
        $TotalComments = $r[0];
        $update = $db->prepare("UPDATE " . OSDB_NEWS . " SET comments = '" . $TotalComments . "' WHERE news_id = '" . $row["news_id"] . "' ");
        $result = $update->execute();
    }
}
开发者ID:WeKiNGSRO,项目名称:OHSystem,代码行数:24,代码来源:admin_func.php

示例5: __construct

 public function __construct($ID)
 {
     $query = db::prepare("SELECT * FROM flight WHERE id=?");
     $query->bindValue(1, $ID);
     try {
         $query->execute();
     } catch (PDOException $e) {
         die($e->getMessage());
     }
     $flightInfo = $query->fetchAll();
     $this->id = $flightInfo[0][0];
     $this->start_location = $flightInfo[0][1];
     $this->end_location = $flightInfo[0][2];
     $this->date_added = $flightInfo[0][3];
     $this->date_updated = $flightInfo[0][4];
 }
开发者ID:simonwoosh,项目名称:cs290,代码行数:16,代码来源:flight.php

示例6: __construct

 public function __construct($ID)
 {
     $query = db::prepare("SELECT * FROM flight_detail_passenger_order WHERE id=?");
     $query->bindValue(1, $ID);
     try {
         $query->execute();
     } catch (PDOException $e) {
         die($e->getMessage());
     }
     $flight_detail_passenger_orderInfo = $query->fetchAll();
     $this->id = $flight_detail_passenger_orderInfo[0][0];
     $this->fdp_id = $flight_detail_passenger_orderInfo[0][1];
     $this->o_id = $flight_detail_passenger_orderInfo[0][2];
     $this->date_added = $flight_detail_passenger_orderInfo[0][3];
     $this->date_updated = $flight_detail_passenger_orderInfo[0][4];
 }
开发者ID:simonwoosh,项目名称:cs290,代码行数:16,代码来源:flight_detail_passenger_order.php

示例7: __construct

 public function __construct($ID)
 {
     $query = db::prepare("SELECT * FROM airport WHERE id=?");
     $query->bindValue(1, $ID);
     try {
         $query->execute();
     } catch (PDOException $e) {
         die($e->getMessage());
     }
     $airportInfo = $query->fetchAll();
     $this->id = $airportInfo[0][0];
     $this->airport_name = $airportInfo[0][1];
     $this->airport_location = $airportInfo[0][2];
     $this->airport_code = $airportInfo[0][3];
     $this->timezone = $airportInfo[0][4];
     $this->date_added = $airportInfo[0][5];
     $this->date_updated = $airportInfo[0][6];
 }
开发者ID:simonwoosh,项目名称:cs290,代码行数:18,代码来源:airport.php

示例8: __construct

 public function __construct($ID)
 {
     $query = db::prepare("SELECT * FROM order WHERE id=?");
     $query->bindValue(1, $ID);
     try {
         $query->execute();
     } catch (PDOException $e) {
         die($e->getMessage());
     }
     $orderInfo = $query->fetchAll();
     $this->id = $orderInfo[0][0];
     $this->user_id = $orderInfo[0][1];
     $this->booking_code = $orderInfo[0][2];
     $this->total_cost = $orderInfo[0][3];
     $this->payment_confirmed = $orderInfo[0][4];
     $this->date_added = $orderInfo[0][5];
     $this->date_updated = $orderInfo[0][6];
 }
开发者ID:simonwoosh,项目名称:cs290,代码行数:18,代码来源:order.php

示例9: creatUserData

 /**
  * Summary of creatUserData 创建用户信息
  * @param mixed $uid
  */
 public function creatUserData($data)
 {
     if ($data['uid'] == '') {
         hb_log('用户id未获取到', '.user_error');
         throw new Exception("用户id未获取到", -1);
     }
     $db = new db();
     $sql = "INSERT INTO `hb_user` (`uid`, `uname`, `pic`)\n        VALUES\n\t(?, ?, ?) ON DUPLICATE KEY UPDATE `uname` = ?,\n\t`pic` = ?";
     $sth = $db->prepare($sql);
     hb_log($data, '.createUserDataDb');
     try {
         $sth->execute([$data['uid'], $data['name'], $data['pic'], $data['name'], $data['pic']]);
         hb_log($data, '.creatUserData');
         $db->commit();
     } catch (Exception $e) {
         hb_log($e, '.user_error');
         return false;
     }
     return true;
 }
开发者ID:kemao,项目名称:php,代码行数:24,代码来源:user.php

示例10: __construct

 public function __construct($ID)
 {
     $query = db::prepare("SELECT * FROM user WHERE id=?");
     $query->bindValue(1, $ID);
     try {
         $query->execute();
     } catch (PDOException $e) {
         die($e->getMessage());
     }
     $userInfo = $query->fetchAll();
     $this->id = $userInfo[0][0];
     $this->first_name = $userInfo[0][1];
     $this->last_name = $userInfo[0][2];
     $this->username = $userInfo[0][3];
     $this->password = $userInfo[0][4];
     $this->email = $userInfo[0][5];
     $this->confirmed = $userInfo[0][6];
     $this->confirm_code = $userInfo[0][7];
     $this->date_added = $userInfo[0][8];
     $this->date_updated = $userInfo[0][9];
 }
开发者ID:simonwoosh,项目名称:cs290,代码行数:21,代码来源:user.php

示例11: __construct

 public function __construct($ID)
 {
     $query = db::prepare("SELECT * FROM flight_detail WHERE id=?");
     $query->bindValue(1, $ID);
     try {
         $query->execute();
     } catch (PDOException $e) {
         die($e->getMessage());
     }
     $flight_detailInfo = $query->fetchAll();
     $this->id = $flight_detailInfo[0][0];
     $this->flight_id = $flight_detailInfo[0][1];
     $this->model_id = $flight_detailInfo[0][2];
     $this->capacity = $flight_detailInfo[0][3];
     $this->flight_status = $flight_detailInfo[0][4];
     $this->delayed_time = $flight_detailInfo[0][5];
     $this->estimated_duration = $flight_detailInfo[0][6];
     $this->departure_time = $flight_detailInfo[0][7];
     $this->unit_price = $flight_detailInfo[0][8];
     $this->date_added = $flight_detailInfo[0][9];
     $this->date_updated = $flight_detailInfo[0][10];
 }
开发者ID:simonwoosh,项目名称:cs290,代码行数:22,代码来源:flight_detail.php

示例12: db

$default_language = 'english';
$DateFormat = '';
$MinDuration = '';
$DefaultMap = 'dota';
$TopPage = 1;
$HeroesPage = '';
$OnlineOfflineOnTopPage = '';
// end
require_once "../../inc/default-constants.php";
require_once "../../inc/common-queries.php";
if (!empty($TimeZone)) {
    date_default_timezone_set($TimeZone);
}
$CronTempFile = '_working.txt';
$db = new db("mysql:host=" . $server . ";dbname=" . $database . "", $username, $password);
$sth = $db->prepare("SET NAMES 'utf8'");
$result = $sth->execute();
//require_once('../../inc/db_connect.php');
$interval = $CronUpdate;
// do every X sec (loaded from config)...
if (isset($_GET["clear"])) {
    $sth = $db->prepare("TRUNCATE TABLE `cron_logs` ");
    $result = $sth->execute();
    header('location: ?' . $CronPasswordLink);
    die;
}
//This is just call from ajax
if (isset($_GET["status"])) {
    if (file_exists($CronTempFile)) {
        $time = filemtime($CronTempFile);
        $next = $time + $interval;
开发者ID:WeKiNGSRO,项目名称:OHSystem,代码行数:31,代码来源:index.php

示例13: setGiftItem

 /**
  * 配置礼品库存
  */
 public function setGiftItem($id, $data)
 {
     $sql = "UPDATE `hb_gift` SET `total`=?,`rate`=? WHERE `id` = ?";
     $db = new db();
     $sth = $db->prepare($sql);
     $sth->execute([$data['total'], $data['rate'], $id]);
     $db->commit();
 }
开发者ID:kemao,项目名称:php,代码行数:11,代码来源:gift.php

示例14: keywordQOverwrite

/**
 * Get keyword question
 *
 * @param array $questions - temp array of questions
 * @param array $random_q_data - a question
 * @param int $q_no - question index in array
 * @param array $used_questions - previsouly used questions
 * @param db $mysqli
 */
function keywordQOverwrite(&$questions, $random_q_data, $q_no, &$used_questions, $mysqli)
{
    // Generate a random question ID from keywords.
    $question_ids = array();
    $question_data = $mysqli->prepare("SELECT DISTINCT k.q_id FROM keywords_question k, questions q WHERE k.q_id = q.q_id AND" . " k.keywordID = ? AND q.deleted is NULL");
    $question_data->bind_param('i', $random_q_data['options'][0]['option_text']);
    $question_data->execute();
    $question_data->bind_result($q_id);
    while ($question_data->fetch()) {
        $question_ids[] = $q_id;
    }
    $question_data->close();
    shuffle($question_ids);
    $try = 0;
    $unique = false;
    while ($unique == false and $try < count($question_ids)) {
        $selected_q_id = $question_ids[$try];
        if (!isset($used_questions[$selected_q_id])) {
            $unique = true;
        }
        $try++;
    }
    $used_questions[$selected_q_id] = 1;
    if ($unique) {
        // Look up selected question and overwrite data.
        $question_data = $mysqli->prepare("SELECT q_type, q_id, score_method, display_method, settings, marks_correct, marks_incorrect," . " marks_partial, theme, scenario, leadin, correct, REPLACE(option_text,'\t','') AS option_text, q_media, q_media_width," . " q_media_height, o_media, o_media_width, o_media_height, notes, q_option_order FROM questions, options WHERE q_id=? AND" . " questions.q_id=options.o_id ORDER BY id_num");
        $question_data->bind_param('i', $selected_q_id);
        $question_data->execute();
        $question_data->store_result();
        $question_data->bind_result($q_type, $q_id, $score_method, $display_method, $settings, $marks_correct, $marks_incorrect, $marks_partial, $theme, $scenario, $leadin, $correct, $option_text, $q_media, $q_media_width, $q_media_height, $o_media, $o_media_width, $o_media_height, $notes, $q_option_order);
        while ($question_data->fetch()) {
            if (!isset($question['q_id']) or $question['q_id'] != $q_id) {
                $question['theme'] = $theme;
                $question['scenario'] = $scenario;
                $question['leadin'] = $leadin;
                $question['notes'] = $notes;
                $question['q_type'] = $q_type;
                $question['q_id'] = $q_id;
                $question['display_pos'] = $q_no;
                $question['score_method'] = $score_method;
                $question['display_method'] = $display_method;
                $question['settings'] = $settings;
                $question['q_media'] = $q_media;
                $question['q_media_width'] = $q_media_width;
                $question['q_media_height'] = $q_media_height;
                $question['q_option_order'] = $q_option_order;
                $question['dismiss'] = '';
            }
            $question['options'][] = array('correct' => $correct, 'option_text' => $option_text, 'o_media' => $o_media, 'o_media_width' => $o_media_width, 'o_media_height' => $o_media_height, 'marks_correct' => $marks_correct, 'marks_incorrect' => $marks_incorrect, 'marks_partial' => $marks_partial);
        }
        echo "\n<input type=\"hidden\" name=\"q" . $q_no . "_randomID\" value=\"" . $question['q_id'] . "\" />\n";
    } else {
        $question['leadin'] = '<span style="color: #f00;">' . $string['error_keywords'] . '</span>';
        $question['q_type'] = 'keyword_based';
        $question['q_id'] = -1;
        $question['display_pos'] = $q_no;
        $question['theme'] = $question['scenario'] = $question['notes'] = $question['score_method'] = $question['q_media'] = '';
        $question['q_media_width'] = $question['q_media_height'] = $question['q_option_order'] = $question['dismiss'] = '';
        $question['options'][] = array();
    }
    $questions[] = $question;
}
开发者ID:vinod-co,项目名称:centa,代码行数:71,代码来源:start.php

示例15: db

$pass = "zYa-2T4-M4U-HK2";
// super secret password for db
$db = "igorrxbi_SD";
// table name for senior design
$mysqli = new db($host, $user, $pass, $db);
/* stablish and check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit;
}
/* write up query and parameters */
$sql = "SELECT * FROM users WHERE id = ?";
/* WHICH USER DO YOU WANT: */
$user_id = rand(1, 6);
/* prepare statement( $stmt ) */
if ($stmt = $mysqli->prepare($sql)) {
    // objective:
    $stmt->mbind_param('d', $user_id);
    $stmt->execute();
    $stmt->store_result();
    /* bind variables to prepared statement */
    $stmt->bind_result($col1, $col2, $col3, $col4, $col5);
    /* fetch values */
    printf("<table>");
    printf("<tr>");
    printf("<th>id</th>");
    printf("<th>username</th>");
    printf("<th>password</th>");
    printf("<th>email</th>");
    printf("<th>xtra</th>");
    while ($stmt->fetch()) {
开发者ID:igorp1,项目名称:Light-Innovation-Technology,代码行数:31,代码来源:test_db.php


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