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


PHP DBConnection::getConnection方法代码示例

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


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

示例1: __construct

 public function __construct($id = NULL)
 {
     $this->db = DBConnection::getConnection();
     if ($id == NULL) {
         $this->new = TRUE;
     } else {
         $id = $this->db->quote($id);
         $query = "SELECT * FROM {$this->sourceTab} WHERE ID={$id}";
         try {
             $res = $this->db->query($query);
             if ($res->rowCount() != 1) {
                 $this->valid = FALSE;
             } else {
                 $info = $res->fetch(PDO::FETCH_ASSOC);
                 $this->nid = $info['NID'];
                 $this->id = $info['ID'];
                 $this->password = $info["PASSWORD"];
                 $this->salt = $info["SALT"];
                 $this->valid = $info["VALID"];
                 $this->admin = $info["ADMIN"];
             }
         } catch (Exception $e) {
             throw new Exception("Impossible to Execute Query that retrieve an user: " . $e->getMessage());
         }
     }
 }
开发者ID:lukdog,项目名称:RaspiControl,代码行数:26,代码来源:User.php

示例2: __construct

 /**
  * Class constructor
  *
  * @param string $readWriteMode "read", "write" or "admin"
  * @throws ControllerException
  */
 public function __construct($readWriteMode = 'write')
 {
     try {
         $dbc = new DBConnection($readWriteMode);
         $this->_dbh = $dbc->getConnection();
         $this->_dbh->autocommit(TRUE);
     } catch (Exception $e) {
         throw new ControllerException('Problem connecting to database: ' . $this->_dbh->error);
     }
 }
开发者ID:kbcmdba,项目名称:pjs2,代码行数:16,代码来源:ControllerBase.php

示例3: delete

 public function delete()
 {
     if (isset($this->id)) {
         $sql = 'DELETE FROM ' . static::$table . ' WHERE id=:id';
         var_dump($sql);
         $dbh = DBConnection::getConnection();
         $sth = $dbh->prepare($sql);
         $sth->setFetchMode(PDO::FETCH_CLASS, get_called_class());
         $sth->execute(['id' => $this->id]);
     }
 }
开发者ID:Tair111,项目名称:bloger,代码行数:11,代码来源:AbstractModel.php

示例4: getCalendarByRange

function getCalendarByRange($id)
{
    try {
        $db = new DBConnection();
        $db->getConnection();
        $sql = "select * from `jqcalendar` where `id` = " . $id;
        $handle = mysql_query($sql);
        //echo $sql;
        $row = mysql_fetch_object($handle);
    } catch (Exception $e) {
    }
    return $row;
}
开发者ID:arjint2004,项目名称:uni912015,代码行数:13,代码来源:edit.php

示例5: userHasRole

 /**
 	returns true if $user has $role; false if $user does not have $role
 */
 public static function userHasRole($user, $role)
 {
     $connection = DBConnection::getConnection();
     $userID = $user->getID();
     $roleID = $role->getID();
     $statement = $connection->prepare("SELECT role_id FROM UserRoles WHERE user_id = :userID AND role_id = :roleID");
     $statement->bindParam(":userID", $userID);
     $statement->bindParam(":roleID", $roleID);
     $statement->execute();
     $result = $statement->fetch();
     $userHasRole = $result !== false;
     return $userHasRole;
 }
开发者ID:laiello,项目名称:gtlolwebsite,代码行数:16,代码来源:RolesRepository.class.php

示例6: retrieveUserWhere

 /**
 	$where = 'WHERE [column_name]=:value'
 	$value = what should replace ':value' in $where
 	returns a User if the user is found or null otherwise
 */
 private static function retrieveUserWhere($where, $value)
 {
     $connection = DBConnection::getConnection();
     $sql = "SELECT id, username, password, name FROM Users WHERE {$where}";
     $parameters[':value'] = $value;
     $statement = DBConnection::executeSQLSelect($sql, $parameters);
     $result = $statement->fetch();
     if ($result === null) {
         return null;
     } else {
         $user = new User($result['id'], $result['username'], $result['password'], $result['name']);
         return $user;
     }
 }
开发者ID:laiello,项目名称:gtlolwebsite,代码行数:19,代码来源:UserRepository.class.php

示例7: delAuthor

function delAuthor()
{
    // TODO : Escape String for SQL Statement
    $authorId = $_GET[AUTHOR_ID];
    $redirectPage = AUTHOR_LIST_PAGE;
    $user = getUserInfo();
    $role = $user->getRole();
    $conn = DBConnection::getConnection($role);
    if ($conn) {
        $result = $conn->deleteAuthor($authorId);
        header("Location: {$redirectPage}");
        exit;
    }
}
开发者ID:VuECASydney,项目名称:LibraryManagement,代码行数:14,代码来源:AddAuthorOk.php

示例8: addAnnouncement

 /**
 	Adds the announcement to the database.
 	returns true if the announcement was inserted successfully
 */
 public static function addAnnouncement($title, $text, $creatorID)
 {
     $sql = "\n\t\t\tINSERT INTO Announcements\n\t\t\t(\n\t\t\t\tannouncer_id,\n\t\t\t\ttitle,\n\t\t\t\tannouncement,\n\t\t\t\tcreated_date\n\t\t\t)\n\t\t\tVALUES\n\t\t\t(\n\t\t\t\t:announcer_id,\n\t\t\t\t:title,\n\t\t\t\t:announcement,\n\t\t\t\t:created_date\n\t\t\t)\n\t\t";
     $dateCreated = new DateTime();
     $strDateCreated = $dateCreated->format('Y-m-d G:i:s');
     $connection = DBConnection::getConnection();
     $statement = $connection->prepare($sql);
     $statement->bindParam(":announcer_id", $creatorID);
     $statement->bindParam(":title", $title);
     $statement->bindParam(":announcement", $text);
     $statement->bindParam(":created_date", $strDateCreated);
     $insertWasSuccessful = $statement->execute();
     return $insertWasSuccessful;
 }
开发者ID:laiello,项目名称:gtlolwebsite,代码行数:18,代码来源:AnnouncementsRepository.class.php

示例9: delCategory

function delCategory()
{
    // TODO : Escape String for SQL Statement
    $categoryId = $_GET[CATEGORY_ID];
    $redirectPage = CATEGORY_LIST_PAGE;
    $user = getUserInfo();
    $role = $user->getRole();
    $conn = DBConnection::getConnection($role);
    if ($conn) {
        $result = $conn->deleteCategory($categoryId);
        header("Location: {$redirectPage}");
        exit;
    }
}
开发者ID:VuECASydney,项目名称:LibraryManagement,代码行数:14,代码来源:AddCategoryOk.php

示例10: delSection

function delSection()
{
    // TODO : Escape String for SQL Statement
    $sectionId = $_GET[SECTION_ID];
    $redirectPage = SECTION_LIST_PAGE;
    $user = getUserInfo();
    $role = $user->getRole();
    $conn = DBConnection::getConnection($role);
    if ($conn) {
        $result = $conn->deleteSection($sectionId);
        header("Location: {$redirectPage}");
        exit;
    }
}
开发者ID:VuECASydney,项目名称:LibraryManagement,代码行数:14,代码来源:AddSectionOk.php

示例11: delPublisher

function delPublisher()
{
    // TODO : Escape String for SQL Statement
    $publisherId = $_GET[PUBLISHER_ID];
    $redirectPage = PUBLISHER_LIST_PAGE;
    $user = getUserInfo();
    $role = $user->getRole();
    $conn = DBConnection::getConnection($role);
    if ($conn) {
        //var_dump($_POST);
        $result = $conn->deletePublisher($publisherId);
        header("Location: {$redirectPage}");
        exit;
    }
}
开发者ID:VuECASydney,项目名称:LibraryManagement,代码行数:15,代码来源:AddPublisherOk.php

示例12: __construct

 /**
  * Constructor
  * @param {string} $file caller for this object
  * @throws Exception if cannot contact database
  */
 function __construct($file)
 {
     // connect database
     $this->file = $file;
     $config = Config::getInstance();
     $h = $config->getEnv("database_host");
     $n = $config->getEnv("database_name");
     $u = base64_decode($config->getEnv("database_user"));
     $p = base64_decode($config->getEnv("database_pass"));
     $l = $config->getEnv("debug_level");
     $this->myLogger = new Logger($file, $l);
     $this->conn = DBConnection::getConnection($h, $n, $u, $p);
     if (!$this->conn) {
         $this->errormsg = "{$file}::construct() cannot contact database";
         throw new Exception($this->errormsg);
     }
     // check if exists resultset::fetch_all() method
     $this->fall = method_exists('mysqli_result', 'fetch_all') ? true : false;
 }
开发者ID:nedy13,项目名称:AgilityContest,代码行数:24,代码来源:DBObject.php

示例13: removeCalendar

function removeCalendar($id)
{
    $ret = array();
    try {
        $db = new DBConnection();
        $db->getConnection();
        $sql = "delete from `jqcalendar` where `id`=" . $id;
        if (mysql_query($sql) == false) {
            $ret['IsSuccess'] = false;
            $ret['Msg'] = mysql_error();
        } else {
            $ret['IsSuccess'] = true;
            $ret['Msg'] = 'Succefully';
        }
    } catch (Exception $e) {
        $ret['IsSuccess'] = false;
        $ret['Msg'] = $e->getMessage();
    }
    return $ret;
}
开发者ID:cntabana,项目名称:inyungu,代码行数:20,代码来源:datafeed.php

示例14: getComments

 /**
  * Will return one of the following:
  *
  *  2-D array of all comments from all users contained the 'Comments' table
  *  OR
  *  A string advising there are no comments in the 'Comments' table
  *
  * @return array|string
  */
 public static function getComments()
 {
     // Get DB Connection
     self::$DB = DBConnection::getConnection();
     // Query for Read-Only. Order by comment date posted
     $result = self::$DB->query("SELECT Comments.comm_Title, Comments.comm_Body, Comments.comm_Date_Posted, Users.user_Username FROM Comments INNER JOIN Users ON Comments.user_ID = Users.user_ID ORDER BY comm_Date_Posted DESC");
     // Array to return to view
     if ($result->rowCount() === 0) {
         $comments = "No comments at this time";
     } else {
         $comments = [];
         // Store the comments to return to the web view
         while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
             // Title, Message, Logged-In Username and Date-Time stamp
             $comments[] = $row;
         }
     }
     // Nullify the DB object
     $DB = null;
     return $comments;
 }
开发者ID:krystofurr,项目名称:HC-CIS,代码行数:30,代码来源:GuestBook.php

示例15: getConnection

 /**
  * 
  * @return type
  */
 protected function getConnection()
 {
     return $this->dbConnection->getConnection();
 }
开发者ID:juyagu,项目名称:Analia,代码行数:8,代码来源:DatabaseObject.php


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