示例#1
0
文件: posts.php 项目: helvete/resyst
    /**
     * 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;
    }
示例#2
0
 /**
  * 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);
 }
示例#3
0
文件: tag.php 项目: helvete/resyst
    /**
     * 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);
    }