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


PHP Connection::getInstance方法代码示例

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


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

示例1: __construct

 /**
  * Method __construct
  * 
  * Cria as configurações padrão do objeto Model
  * 
  * @param string
  */
 public function __construct($table = null)
 {
     if ($table !== null) {
         $this->setTable($table);
     }
     $this->conn = Connection::getInstance();
 }
开发者ID:alanfm,项目名称:microasterisco,代码行数:14,代码来源:Model.php

示例2: signup

 public static function signup()
 {
     $dbh = Connection::getInstance()->connect();
     if (isset($_POST['email']) && !isset($_POST['username'])) {
         $email = $_POST['email'];
         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             echo "invalid";
         } else {
             $stmt = $dbh->prepare("SELECT id FROM users WHERE email=:email");
             $stmt->bindParam(':email', $email);
             $stmt->execute();
             $stmt = $stmt->fetch();
             if ($stmt) {
                 echo "exist";
             } else {
                 echo "ok";
             }
         }
     }
     if (isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password'])) {
         $username = $_POST['username'];
         $email = $_POST['email'];
         $password = $_POST['password'];
         $stmt = $dbh->prepare("INSERT INTO users (username, email, password) VALUES (:username, :email, :password)");
         $stmt->bindParam(':username', $username);
         $stmt->bindParam(':email', $email);
         $stmt->bindParam(':password', $password);
         $stmt->execute();
     }
 }
开发者ID:emaxv,项目名称:DataBase,代码行数:30,代码来源:user.class.php

示例3: delete

 public static function delete($id)
 {
     $db = Connection::getInstance();
     $sql = "DELETE FROM sse_answer WHERE thread_id = :id";
     $statement = $db->prepare($sql);
     $statement->execute(array(':id' => $id));
 }
开发者ID:rahmanadianto,项目名称:IF3110-2015-T1,代码行数:7,代码来源:class.answer.php

示例4: setIsdatepassed

 public static function setIsdatepassed($isdatepassed)
 {
     $db = Connection::getInstance();
     $mysqli = $db->getConnection();
     $query = "update deadline set isdatepassed='{$isdatepassed}';";
     $result = $mysqli->query($query);
     return $result;
 }
开发者ID:dushaniw,项目名称:Grade1_admission_system,代码行数:8,代码来源:DBDeadlineController.php

示例5: countPosts

 public function countPosts()
 {
     $conn = Connection::getInstance("read");
     $command = "SELECT COUNT(*) AS count \n\t\t\t\t\tFROM post_to_cats \n\t\t\t\t\tWHERE cat_id = {$this->id}";
     $r = $conn->execObject($command);
     $row = mysqli_fetch_assoc($r);
     return $row['count'];
 }
开发者ID:sheyooo,项目名称:testify,代码行数:8,代码来源:Category.php

示例6: refundOrder

 public static function refundOrder($orderCode, $amount)
 {
     if (!empty($amount) && is_numeric($amount)) {
         $json = json_encode(array('refundAmount' => "{$amount}"));
     } else {
         $json = false;
     }
     Connection::getInstance()->sendRequest('orders/' . $orderCode . '/refund', $json, false);
 }
开发者ID:worldpay,项目名称:worldpay-lib-php,代码行数:9,代码来源:OrderService.php

示例7: delete

 public function delete($school_id)
 {
     $conn = Connection::getInstance("write");
     $command = "DELETE FROM newsletter\n\t\t\t\t\tWHERE news_id = {$this->id}\n\t\t\t\t\tAND school_id = {$school_id}";
     if ($conn->execDelete($command)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:sheyooo,项目名称:testify,代码行数:10,代码来源:Newsletter.php

示例8: editCategory6

 public static function editCategory6($category)
 {
     $db = Connection::getInstance();
     $mysqli = $db->getConnection();
     $nic = $category->getNic();
     $dateOfReturned = $category->getDateOfReturned();
     $periodAboardStay = $category->getPerioadAbroadStay();
     $reasonsForStay = $category->getReasonsForStay();
     $query = "update personComingFromAboard set dateOfReturned='{$dateOfReturned}',periodAboardStay='{$periodAboardStay}',reasonsForStay='{$reasonsForStay}' where NIC='{$nic}'";
     return $mysqli->query($query);
 }
开发者ID:dushaniw,项目名称:Grade1_admission_system,代码行数:11,代码来源:DBCategory6Controller.php

示例9: delete

 public static function delete($id)
 {
     $db = Connection::getInstance();
     // delete answer
     require_once ROOT . DS . 'application' . DS . 'model' . DS . 'class.answer.php';
     Answer::delete($id);
     // delete thread
     $sql = "DELETE FROM sse_thread WHERE thread_id = :id";
     $statement = $db->prepare($sql);
     $statement->execute(array(':id' => $id));
 }
开发者ID:rahmanadianto,项目名称:IF3110-2015-T1,代码行数:11,代码来源:class.thread.php

示例10: findAll

 public static function findAll()
 {
     $database = Connection::getInstance();
     $results = $database->run('SELECT * FROM chapters');
     // Hydrate the objects
     $chapters = array();
     foreach ($results as $result) {
         $chapters[] = self::factory($result);
     }
     return $chapters;
 }
开发者ID:rmill,项目名称:cb-comic,代码行数:11,代码来源:Chapter.php

示例11: __construct

 /**
  * Initialize class
  *
  * @param string $host
  * @param string $username
  * @param string $passord
  * @param string $database
  * @return void
  */
 public function __construct($host, $username = NULL, $password = NULL, $database = NULL, $newconnection = true)
 {
     $this->traitConstructor();
     if (is_array($host)) {
         $credentials = $host;
     } else {
         $credentials = ['host' => $host, 'username' => $username, 'password' => $password, 'database' => $database];
     }
     $this->connection = $newconnection ? new Connection($credentials) : Connection::getInstance() ?: new Connection($credentials);
     $this->results = new Collection();
     $this->query("SET NAMES UTF8");
 }
开发者ID:flo5581,项目名称:mysql,代码行数:21,代码来源:MySQL.php

示例12: DirectQuery

 function DirectQuery($driver, $host = NULL, $dbname = NULL, $user = NULL, $pass = NULL)
 {
     if (Connection::validClass($driver)) {
         $this->conn =& $driver;
     } else {
         if (URL::validclass($driver)) {
             $this->conn =& Connection::getInstance($driver);
         } else {
             $this->conn =& Connection::getInstance($driver, $host, $dbname, $user, $pass);
         }
     }
 }
开发者ID:alexpagnoni,项目名称:jphp,代码行数:12,代码来源:DirectQuery.php

示例13: __construct

 /**
  * Library constructor
  * @param string $service_key
  *  Your worldpay service key
  * @param int $timeout
  *  Connection timeout length
  * */
 public function __construct($service_key = false, $timeout = false)
 {
     if ($service_key == false) {
         Error::throwError("key");
     }
     $this->connection = Connection::getInstance();
     $this->setServiceKey($service_key);
     if ($timeout !== false) {
         $this->setTimeout($timeout);
     }
     //
 }
开发者ID:worldpay,项目名称:worldpay-lib-php,代码行数:19,代码来源:Worldpay.php

示例14: exportCSV

function exportCSV($query, $headerArray, $filename)
{
    $conn = Connection::getInstance();
    $statement = $conn->db->prepare($query);
    $statement->setFetchMode(PDO::FETCH_ASSOC);
    $statement->execute();
    $csv = Writer::createFromFileObject(new SplTempFileObject());
    $csv->insertOne($headerArray);
    $csv->insertAll($statement);
    $csv->output($filename . '.csv');
    die;
}
开发者ID:Amar444,项目名称:Weathernet-backend,代码行数:12,代码来源:index.php

示例15: editPPAchievement

 public static function editPPAchievement($achievement)
 {
     $db = Connection::getInstance();
     $mysqli = $db->getConnection();
     $schoolId = $achievement->getSchoolId();
     $nic = $achievement->getNIC();
     $achievementId = $achievement->getAchievementID();
     $type = $achievement->getType();
     $achievementDetail = $achievement->getAchievementDetail();
     $query = "update pastpupil_Achievement set type='{$type}', achievementDetail='{$achievementDetail}' where schoolId='{$schoolId}' and NIC='{$nic}' and  AchievementId='{$achievementId}'";
     return $mysqli->query($query);
 }
开发者ID:dushaniw,项目名称:Grade1_admission_system,代码行数:12,代码来源:DBPPAchievementController.php


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