<noframes id="bhrfl"><address id="bhrfl"></address>

    <address id="bhrfl"></address>

    <noframes id="bhrfl"><address id="bhrfl"><th id="bhrfl"></th></address>

    <form id="bhrfl"><th id="bhrfl"><progress id="bhrfl"></progress></th></form>

    <em id="bhrfl"><span id="bhrfl"></span></em>

    全部
    常見問題
    產品動態
    精選推薦

    PHP PDOConnection類代碼示例

    管理 管理 編輯 刪除

    本文整理匯總了PHP中PDOConnection類的典型用法代碼示例。如果您正苦于以下問題:PHP PDOConnection類的具體用法?PHP PDOConnection怎么用?PHP PDOConnection使用的例子?那么恭喜您, 這里精選的類代碼示例或許可以為您提供幫助。

    在下文中一共展示了PDOConnection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點贊,您的評價將有助于我們的系統推薦出更棒的PHP代碼示例。

    示例1: get_addresses

    function get_addresses($values = NULL)
    {
        if (!(isset($values['user_id']) || isset($values['customer_id']))) {
            throw new Exception("Must provide user_id or customer_id");
        }
        $query = "SELECT a.id address_id, a.last_updated, a.name, address1, address2, city, state, zipcode, type FROM addresses a \n            LEFT JOIN user_addresses ua ON a.id = ua.address_id \n            LEFT JOIN customer_addresses ca ON a.id = ca.address_id \n        WHERE (ua.user_id = :user_id or ca.customer_id = :customer_id) ";
        $execArray['user_id'] = isset($values['user_id']) ? $values['user_id'] : -1;
        $execArray['customer_id'] = isset($values['customer_id']) ? $values['customer_id'] : -1;
        if (isset($values['address_id'])) {
            $query .= " AND a.id = :address_id ";
            $execArray['address_id'] = (int) $values['address_id'];
        }
        if (isset($values['type'])) {
            $query .= " AND type = :type ";
            $execArray['type'] = (int) $values['type'];
        }
        $dbh = new PDOConnection();
        $sth = $dbh->prepare($query);
        if (!$sth->execute($execArray)) {
            throw new Exception($sth->errorInfo()[2]);
        }
        $addressArray = array();
        foreach ($sth->fetchAll(PDO::FETCH_ASSOC) as $row) {
            $addressArray[] = $row;
        }
        return $addressArray;
    }

    示例2: update_address

    function update_address($addressInfo)
    {
        if (!(isset($addressInfo['address_id']) && (isset($addressInfo['customer_id']) || isset($addressInfo['user_id'])))) {
            throw new Exception("ERROR: address_id and customer_id or user_id required");
        }
        $oldInfo = get_addresses($addressInfo)[0];
        //takes customer/user id and address id
        if (empty($oldInfo)) {
            throw new Exception("Could not find address id for customer or user.");
        }
        $addressInfo = array_replace($oldInfo, $addressInfo);
        $query = "UPDATE addresses SET name = :name, address1 = :address1, address2 = :address2, city = :city, state = :state, zipcode = :zipcode, type = :type WHERE id = :address_id";
        $dbh = new PDOConnection();
        $sth = $dbh->prepare($query);
        $sth->bindParam(':name', $addressInfo['name']);
        $sth->bindParam(':address1', $addressInfo['address1']);
        $sth->bindParam(':address2', $addressInfo['address2']);
        $sth->bindParam(':city', $addressInfo['city']);
        $sth->bindParam(':state', $addressInfo['state']);
        $sth->bindParam(':zipcode', $addressInfo['zipcode']);
        $sth->bindParam(':type', $addressInfo['type'], PDO::PARAM_INT);
        $sth->bindParam(':address_id', $addressInfo['address_id'], PDO::PARAM_INT);
        if (!$sth->execute()) {
            throw new Exception("ERROR: could not update address - " . $sth->errorInfo()[2]);
        }
        return $addressInfo;
    }

    示例3: update_inventory

    function update_inventory($inventoryInfo)
    {
        if (!isset($inventoryInfo['inventory'])) {
            throw new Exception('Must provide \'inventory\'');
        }
        $dbh = new PDOConnection();
        $query = "INSERT INTO inventory(\n                product_id, unit_id, quantity\n            )\n            VALUES(\n                :product_id, :unit_id, :quantity\n            )\n            ON DUPLICATE KEY UPDATE\n                quantity = :quantity";
        $product_id = -1;
        $unit_id = -1;
        $qantity = -1;
        $response = '';
        $sth = $dbh->prepare($query);
        $sth->bindParam(':product_id', $product_id, PDO::PARAM_INT);
        $sth->bindParam(':unit_id', $unit_id, PDO::PARAM_INT);
        $sth->bindParam(':quantity', $quantity);
        foreach ($inventoryInfo['inventory'] as $inventory) {
            $product_id = $inventory['product_id'];
            $unit_id = $inventory['unit_id'];
            $quantity = $inventory['quantity_id'];
            if (!$sth->execute()) {
                throw new Exception($sth->errorInfo()[2]);
            }
        }
        return true;
    }
    

    示例4: update_unit

    function update_unit($unitInfo)
    {
        if (!isset($unitInfo['id'])) {
            throw new Exception("Product id required.");
        }
        $id = $unitInfo['id'];
        $dbh = new PDOConnection();
        $oldValues = get_units(array('id' => $id))[0];
        //returns array of units
        if (empty($oldValues)) {
            throw new Exception("Product id: '" . $id . "' not found!");
        }
        $query = "UPDATE units \n        SET code = :code, \n            description = :description, \n            active = :active\n        WHERE id = :id";
        $sth = $dbh->prepare($query);
        $code = isset($unitInfo['code']) ? $unitInfo['code'] : $oldValues['code'];
        $description = isset($unitInfo['description']) ? $unitInfo['description'] : $oldValues['description'];
        $active = isset($unitInfo['active']) ? $unitInfo['active'] : $oldValues['active'];
        $sth->bindParam(':id', $id, PDO::PARAM_INT);
        $sth->bindParam(':code', $code);
        $sth->bindParam(':description', $description);
        $sth->bindParam(':active', $active, PDO::PARAM_INT);
        if (!$sth->execute()) {
            throw new Exception($sth->errorInfo()[2]);
        }
        return true;
    }

    示例5: update_product

    function update_product($prodInfo)
    {
        if (!isset($prodInfo['id'])) {
            throw new Exception("Product id required.");
        }
        $dbh = new PDOConnection();
        $query = "SELECT id,code,description,price,active,last_updated FROM products WHERE id = :id";
        $sth = $dbh->prepare($query);
        $id = $prodInfo['id'];
        $sth->bindParam(':id', $id, PDO::PARAM_INT);
        if (!$sth->execute()) {
            throw new Exception($sth->errorInfo()[2]);
        }
        if (!($oldValues = $sth->fetch())) {
            throw new Exception("Product id: '" . $id . "' not found!");
        }
        $query = "UPDATE products \n        SET code = :code, \n            description = :description, \n            price = :price, \n            class = :class, \n            active = :active \n        WHERE id = :id";
        $sth = $dbh->prepare($query);
        $code = isset($prodInfo['code']) ? $prodInfo['code'] : $oldValues['code'];
        $description = isset($prodInfo['description']) ? $prodInfo['description'] : $oldValues['description'];
        $price = isset($prodInfo['price']) ? $prodInfo['price'] : $oldValues['price'];
        $class = isset($prodInfo['class']) ? $prodInfo['class'] : $oldValues['class'];
        $active = isset($prodInfo['active']) ? $prodInfo['active'] : $oldValues['active'];
        $sth->bindParam(':id', $id, PDO::PARAM_INT);
        $sth->bindParam(':code', $code);
        $sth->bindParam(':description', $description);
        $sth->bindParam(':price', $price);
        $sth->bindParam(':class', $class, PDO::PARAM_INT);
        $sth->bindParam(':active', $active, PDO::PARAM_INT);
        $sth->execute();
        return true;
    }
    

    示例6: verifyUserIsAdmin

    function verifyUserIsAdmin($username)
    {
        $dbh = new PDOConnection();
        $query = 'SELECT user_id FROM admins JOIN users ON users.id = user_id WHERE username = :username';
        $sth = $dbh->prepare($query);
        $sth->bindParam(':username', $username, PDO::PARAM_STR);
        if (!$sth->execute()) {
            throw new Exception($sth->errorInfo()[2]);
        }
        $result = $sth->fetchAll();
        $retval = !empty($result);
        return $retval;
    }
    

    示例7: get_product_classes

    function get_product_classes($classFilters = NULL)
    {
        $dbh = new PDOConnection();
        $query = "SELECT * FROM product_classes ";
        $classArray = array();
        $sth = $dbh->prepare($query);
        $sth->execute();
        $result = $sth->fetchAll(PDO::FETCH_ASSOC);
        foreach ($result as $row) {
            $classArray[] = $row;
        }
        return $classArray;
    }

    示例8: add_product_class

    function add_product_class($info)
    {
        $dbh = new PDOConnection();
        $product_id = isset($info['product_id']) ? $info['product_id'] : '';
        $unit_id = isset($info['unit_id']) ? $info['unit_id'] : '';
        $description = isset($info['description']) ? $info['description'] : '';
        if (!$product_id) {
            $product_code = isset($info['product_code']) ? $info['product_code'] : '';
            if (!$product_code) {
                throw new Exception("Product id or code required");
            }
            $query = "SELECT id FROM products WHERE code = :code";
            $sth = $dbh->prepare($query);
            $sth->bindParam(':code', $product_code);
            if (!$sth->execute()) {
                throw new Exception($sth->errorInfo()[2]);
            }
            $product_id = $sth->fetchColumn();
        }
        if (!$unit_id) {
            $unit_code = isset($info['product_code']) ? $info['unit_code'] : '';
            if (!$unit_code) {
                throw new Exception("Unit id or code required");
            }
            $query = "SELECT id FROM units WHERE code = :code";
            $sth = $dbh->prepare($query);
            $sth->bindParam(':code', $unit_code);
            if (!$sth->execute()) {
                throw new Exception($sth->errorInfo[2]);
            }
            $unit_id = $sth->fetchColumn();
        }
        $query = "SELECT id FROM product_unit WHERE product_id = :pid AND unit_id = :uid";
        $sth = $dbh->prepare($query);
        $sth->bindParam(':pid', $product_id, PDO::PARAM_INT);
        $sth->bindParam(':uid', $unit_id, PDO::PARAM_INT);
        $sth->execute();
        if ($sth->rowCount() > 0) {
            throw new Exception("Product/unit entry already exists.");
        }
        $query = "INSERT INTO product_unit(product_id,unit_id,description) VALUES(:pid,:uid,desc)";
        $sth = $dbh->prepare($query);
        $sth->bindParam(':pid', $product_id, PDO::PARAM_INT);
        $sth->bindParam(':uid', $unit_id, PDO::PARAM_INT);
        $sth->bindParam(':description', $description, PDO::PARAM_STR);
        if (!$sth->execute()) {
            throw new Exception($sth->errorInfo()[2]);
        }
        return true;
    }

    示例9: initialize

     /**
      * @codeCoverageIgnore
      */
     protected static function initialize()
     {
         static::$classNS = get_called_class();
         static::$tableName = static::getTableName(static::$classNS);
         $pdo = PDOConnection::getInstance();
         static::$DBH = $pdo->connect();
     }

    示例10: revisionData

     public function revisionData()
     {
         $dao = new JobRevisionDataDao(PDOConnection::connectINIT());
         $data = $dao->getData($this->request->id_job, $this->auth_param);
         $result = new Json_RevisionData_Job($data);
         $this->response->json($result->render());
     }

    示例11: obtain

     public static function obtain($server = null, $user = null, $pass = null, $database = null)
     {
         if (!self::$instance) {
             self::$instance = new PDOConnection($server, $user, $pass, $database);
         }
         return self::$instance;
     }
    

    示例12: add_product_class

    function add_product_class($classArray)
    {
        $dbh = new PDOConnection();
        $code = $classArray['code'];
        $description = $classArray['description'];
        $query = "SELECT code FROM product_classes where code = :code";
        $sth = $dbh->prepare($query);
        $sth->bindParam(':code', $code, PDO::PARAM_STR);
        $sth->execute();
        if ($sth->rowCount() > 0) {
            throw new Exception("Class code exists");
        }
        $query = "INSERT INTO product_classes(description,code) VALUES(:description,:code)";
        $sth = $dbh->prepare($query);
        $sth->bindParam(':code', $code, PDO::PARAM_STR);
        $sth->bindParam(':description', $description, PDO::PARAM_STR);
        return $sth->execute();
    }

    示例13: get_units

    function get_units($filters = NULL)
    {
        $dbh = new PDOConnection();
        $query = "SELECT id, code, description, active, last_updated FROM units ";
        $query .= GetOptionalParams($filters);
        $units = array();
        $sth = $dbh->prepare($query);
        if (isset($filters['id'])) {
            $sth->bindParam(':id', $filters['id'], PDO::PARAM_INT);
        } elseif (isset($filters['code'])) {
            $sth->bindParam(':code', $filters['code']);
        }
        $sth->execute();
        $result = $sth->fetchAll(PDO::FETCH_ASSOC);
        foreach ($result as $row) {
            $units[] = $row;
        }
        return $units;
    }

    示例14: getPosiciones

     public function getPosiciones()
     {
         $list = array();
         $db = PDOConnection::getInstance();
         $req = $db->prepare('SELECT posicion as posicion, FK_pincho_prem as id_pincho FROM premiados WHERE FK_premio_prem =?');
         $req->execute(array($this->getId()));
         foreach ($req->fetchAll() as $posicion) {
             $list[] = array($posicion['posicion'], Pincho::find($posicion['id_pincho'])->getNombre());
         }
         return $list;
     }

    示例15: get_customers

    function get_customers($values = NULL)
    {
        $dbh = new PDOConnection();
        $query = "SELECT id, code, name, active, last_updated FROM customers ";
        if (isset($values['id'])) {
            $optional[] = "id = :id ";
        }
        if (isset($values['code'])) {
            $optional[] = "code = :code ";
        }
        if (isset($values['active'])) {
            $optional[] = "active = :active ";
        }
        if (!empty($optional)) {
            $query .= ' WHERE ';
            $countOpt = count($optional);
            for ($i = 0; $i < $countOpt; ++$i) {
                $query .= ($i > 0 ? ' AND ' : ' ') . $optional[$i];
            }
        }
        $sth = $dbh->prepare($query);
        if (isset($values['id'])) {
            $sth->bindParam(':id', $values['id'], PDO::PARAM_INT);
        }
        if (isset($values['code'])) {
            $sth->bindParam(':code', $values['code'], PDO::PARAM_STR);
        }
        if (isset($values['active'])) {
            $sth->bindParam(':active', $values['active'], PDO::PARAM_INT);
        }
        if (!$sth->execute()) {
            throw new Exception($sth->errorInfo()[2]);
        }
        $customerArray = array();
        foreach ($sth->fetchAll(PDO::FETCH_ASSOC) as $row) {
            $customerArray[] = $row;
        }
        return array('customers' => $customerArray);
    }


    請登錄后查看

    CRMEB-慕白寒窗雪 最后編輯于2023-06-29 14:50:05

    快捷回復
    回復
    回復
    回復({{post_count}}) {{!is_user ? '我的回復' :'全部回復'}}
    排序 默認正序 回復倒序 點贊倒序

    {{item.user_info.nickname ? item.user_info.nickname : item.user_name}} LV.{{ item.user_info.bbs_level }}

    作者 管理員 企業

    {{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推薦': '推薦'}}
    {{item.is_suggest == 1? '取消推薦': '推薦'}}
    沙發 板凳 地板 {{item.floor}}#
    {{item.user_info.title || '暫無簡介'}}
    附件

    {{itemf.name}}

    {{item.created_at}}  {{item.ip_address}}
    打賞
    已打賞¥{{item.reward_price}}
    {{item.like_count}}
    {{item.showReply ? '取消回復' : '回復'}}
    刪除
    回復
    回復

    {{itemc.user_info.nickname}}

    {{itemc.user_name}}

    回復 {{itemc.comment_user_info.nickname}}

    附件

    {{itemf.name}}

    {{itemc.created_at}}
    打賞
    已打賞¥{{itemc.reward_price}}
    {{itemc.like_count}}
    {{itemc.showReply ? '取消回復' : '回復'}}
    刪除
    回復
    回復
    查看更多
    打賞
    已打賞¥{{reward_price}}
    2224
    {{like_count}}
    {{collect_count}}
    添加回復 ({{post_count}})

    相關推薦

    快速安全登錄

    使用微信掃碼登錄
    {{item.label}} 加精
    {{item.label}} {{item.label}} 板塊推薦 常見問題 產品動態 精選推薦 首頁頭條 首頁動態 首頁推薦
    取 消 確 定
    回復
    回復
    問題:
    問題自動獲取的帖子內容,不準確時需要手動修改. [獲取答案]
    答案:
    提交
    bug 需求 取 消 確 定
    打賞金額
    當前余額:¥{{rewardUserInfo.reward_price}}
    {{item.price}}元
    請輸入 0.1-{{reward_max_price}} 范圍內的數值
    打賞成功
    ¥{{price}}
    完成 確認打賞

    微信登錄/注冊

    切換手機號登錄

    {{ bind_phone ? '綁定手機' : '手機登錄'}}

    {{codeText}}
    切換微信登錄/注冊
    暫不綁定
    亚洲欧美字幕
    CRMEB客服

    CRMEB咨詢熱線 咨詢熱線

    400-8888-794

    微信掃碼咨詢

    CRMEB開源商城下載 源碼下載 CRMEB幫助文檔 幫助文檔
    返回頂部 返回頂部
    CRMEB客服