当前位置: 首页>>代码示例>>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;未经允许,请勿转载。