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


PHP DBConnector::getPDO方法代碼示例

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


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

示例1: get

    /**
     * Get posts from DB according to input parameters
     *
     * @param  int		$count
     * @param  int		$id
     * @param  string	$tag
     * @return Posts
     */
    public function get($count = false, $id = false, $tag = false)
    {
        $queryString = '
			SELECT resyst_db.time as timestamp, resyst_db.name as title,
				resyst_db.text as contents, resyst_db.id as id,
				resyst_tag.id as tag_id, resyst_tag.tagname as tag_name,
				resyst_tag.parenttag as tag_parentName,
				resyst_tag.colour as tag_colour
			FROM resyst_db
			INNER JOIN resyst_tag
				ON resyst_db.tag = resyst_tag.id
			' . ($id ? "WHERE resyst_db.id = {$id}" : '') . '
			' . ($tag ? "WHERE resyst_tag.tagname = '{$tag}'" : '') . '
			ORDER BY id DESC
			' . ($count ? "LIMIT {$count}" : '') . '
		';
        $pdo = DBConnector::getPDO();
        $query = $pdo->prepare($queryString);
        $query->execute(array());
        $result = $query->fetchAll(PDO::FETCH_ASSOC);
        foreach ($result as &$postData) {
            $postData['contents'] = html_entity_decode($postData['contents']);
            $postData = $this->_processTagData($postData);
            $this->_posts[] = new Post($postData);
        }
        return $this;
    }
開發者ID:helvete,項目名稱:resyst,代碼行數:35,代碼來源:posts.php

示例2: validateLogin

 /**
  * Validate login credentials
  *
  * @param  string	$login
  * @param  string	$password
  * @return string|false
  */
 public static function validateLogin($login, $password)
 {
     include_once "./pdo_connect.php";
     $pdo = DBConnector::getPDO();
     $query = "\n\t\t\tSELECT COUNT(1)\n\t\t\tFROM resyst_user\n\t\t\tWHERE login = :login\n\t\t\t\tAND password = MD5(:password)\n\t\t\t";
     $stmt = $pdo->prepare($query);
     $stmt->execute(array(':login' => $login, ':password' => $password));
     return (int) $stmt->fetch(PDO::FETCH_COLUMN);
 }
開發者ID:helvete,項目名稱:resyst,代碼行數:16,代碼來源:statLib.php

示例3: _retrieveTagData

    /**
     * Retrieve tag data from DB
     *
     * @return array
     */
    private static function _retrieveTagData()
    {
        $queryString = '
			SELECT resyst_tag.id as id, resyst_tag.tagname as name,
				resyst_tag.parenttag as parentName, resyst_tag.colour as colour
			FROM resyst_tag
			ORDER BY parentName, id ASC
		';
        $pdo = DBConnector::getPDO();
        $query = $pdo->prepare($queryString);
        $query->execute(array());
        return $query->fetchAll(PDO::FETCH_ASSOC);
    }
開發者ID:helvete,項目名稱:resyst,代碼行數:18,代碼來源:tag.php


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