本文整理汇总了PHP中DBConnection::executeSQLSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnection::executeSQLSelect方法的具体用法?PHP DBConnection::executeSQLSelect怎么用?PHP DBConnection::executeSQLSelect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnection
的用法示例。
在下文中一共展示了DBConnection::executeSQLSelect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: announcement
/**
$afterDateTime: The earliest date/time that the announcement(s) was created; null if no restriction
$maxNumAnnouncements: The maximum number of announcements to return; null if no limit;
$userID: The id of the user who created the announcement(s); null if no restriction
*/
public static function retrieveAnnouncements($afterDateTime = null, $maxNumAnnouncements = null, $userID = null)
{
$result = buildRetrieveSQL($afterDateTime, $maxNumAnnouncements, $userID);
$strSQL = $result[0];
$parameters = $result[1];
$statement = DBConnection::executeSQLSelect($strSQL, $parameters);
$announcements = array();
$i = 0;
while ($row = $statement->fetch()) {
$announcements[$i++] = self::convertRowToAnnouncement($row);
}
return $announcements;
}
示例2: 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;
}
}