當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Connect::getInstance方法代碼示例

本文整理匯總了PHP中Connect::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connect::getInstance方法的具體用法?PHP Connect::getInstance怎麽用?PHP Connect::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Connect的用法示例。


在下文中一共展示了Connect::getInstance方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: insert

 public function insert($obj)
 {
     try {
         $query = "INSERT INTO portalleg." . $this->table . " (\n                name,\n                login,\n                mail,\n                pass,\n                type,\n                photo,\n            ) VALUES (\n                :name,\n                :login,\n                :mail,\n                :pass,\n                :type,\n                :photo\n            )";
         $sql = Connect::getInstance()->prepare($query);
         $sql->bindValue(':name', $obj->getName(), PDO::PARAM_STR);
         $sql->bindValue(':login', $obj->getLogin(), PDO::PARAM_STR);
         $sql->bindValue(':mail', $obj->getMail(), PDO::PARAM_STR);
         $sql->bindValue(':pass', $obj->getPass(), PDO::PARAM_STR);
         $sql->bindValue(':type', $obj->getType(), PDO::PARAM_INT);
         $sql->bindValue(':photo', $obj->getPhoto(), PDO::PARAM_STR);
         return $sql->execute();
     } catch (Exception $e) {
         Lib::warning($e);
     }
 }
開發者ID:dnielrodrigues,項目名稱:cristal,代碼行數:16,代碼來源:CristalUserDao.php

示例2: __construct

 public function __construct()
 {
     self::$Connect = Connect::getInstance(DB_NAME, DB_HOST, DB_USER, DB_PASS);
     $this->query = isset($this->query) ? $this->query : null;
 }
開發者ID:nicoavn,項目名稱:GreenJobs,代碼行數:5,代碼來源:QueryManager.php

示例3: delete_common

 public function delete_common($table, $filters, $query_extra)
 {
     //criando o objeto pdo...
     $pdo = parent::getInstance();
     //filtros
     foreach ($filters as $key => $value) {
         $filters_delete = "{$key}=:{$key} AND ";
     }
     //removendo ultimo "AND";
     $filters_delete = substr($filters_delete, 0, -4);
     //preparando query apartir dos campos($fields) e os parametros de valores nomeados($values)
     $query = "DELETE FROM {$table} WHERE {$filters_delete};";
     //se a consulta precisar de algo mais..
     if ($query_extra != "") {
         $query .= $query_extra;
     }
     //echo $query,'<br>';
     //continuação da preparação da query...
     $statement = $pdo->prepare($query);
     if (!$statement) {
         echo "\\PDO::errorInfo():\n";
         print_r($dbh->errorInfo());
     }
     //substituindo os parametros dos filtros nomeados pelos verdadeiros valores, ex: ":name" por "Alessandro"
     foreach ($filters as $key => $value) {
         //$parameters[":$key"] = $value;
         $statement->bindValue(":{$key}", $value, PDO::PARAM_STR);
     }
     //$statement->debugDumpParams();
     //executando a query já com seus valores
     if ($statement->execute()) {
         //se der certo retorna true...
         return true;
     } else {
         //se não der certo, retornará false...
         return false;
     }
 }
開發者ID:mvnp,項目名稱:PHPeste_minicurso,代碼行數:38,代碼來源:Manager.class.php

示例4: __construct

 public function __construct($dbarr = array())
 {
     $this->connect = Connect::getInstance($dbarr);
 }
開發者ID:tiger2soft,項目名稱:LycPHP,代碼行數:4,代碼來源:Manager.class.php

示例5: __construct

 function __construct()
 {
     $this->db = Connect::getInstance();
 }
開發者ID:Zenya3000,項目名稱:GNS,代碼行數:4,代碼來源:Model.php

示例6: find

 public function find($value, $by)
 {
     try {
         $sql = "SELECT * FROM " . $this->table . " WHERE " . $by . " = :value";
         $sql = Connect::getInstance()->prepare($sql);
         $sql->bindValue(":value", $value);
         $sql->execute();
         return $sql->fetch(PDO::FETCH_ASSOC);
     } catch (Exception $e) {
         Lib::dbWarning($e);
         die;
     }
 }
開發者ID:dnielrodrigues,項目名稱:cristal,代碼行數:13,代碼來源:MainDao.php


注:本文中的Connect::getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。