本文整理汇总了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;
}
示例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);
}
示例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);
}