本文整理汇总了PHP中Listing::ngToDateTime方法的典型用法代码示例。如果您正苦于以下问题:PHP Listing::ngToDateTime方法的具体用法?PHP Listing::ngToDateTime怎么用?PHP Listing::ngToDateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Listing
的用法示例。
在下文中一共展示了Listing::ngToDateTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getListingByListingPostTime
/**
* gets the listing by listing post time
*
* @param PDO $pdo pointer to PDO connection
* @param int $listingPostTime listing post time to search for
* @return mixed listing found or null if not found
* @throws PDO Exceptions when my SQL related errors occur
**/
public static function getListingByListingPostTime(PDO $pdo, $listingPostTime)
{
//sanitize the listingPostTime before searching
try {
//if we get an angular-style time value, filter it and convert it
if (is_numeric($listingPostTime) === true) {
filter_var($listingPostTime, FILTER_VALIDATE_INT);
if ($listingPostTime === false) {
throw new InvalidArgumentException("listing post time is not valid");
}
$listingPostTime = Listing::ngToDateTime($listingPostTime);
}
$listingPostTime = Listing::validateDate($listingPostTime);
} catch (InvalidArgumentException $invalidArgument) {
throw new InvalidArgumentException($invalidArgument->getMessage(), 0, $invalidArgument);
} catch (RangeException $range) {
throw new RangeException($range->getMessage(), 0, $range);
}
$sunrise = $listingPostTime->format("Y-m-d") . " 00:00:00";
$sunset = $listingPostTime->format("Y-m-d") . " 23:59:59";
//create query template
$query = "SELECT listingId,orgId,listingClaimedBy,listingClosed,listingCost,listingMemo,listingParentId,listingPostTime,listingTypeId FROM listing WHERE listingPostTime >= :sunrise AND listingPostTime <= :sunset";
$statement = $pdo->prepare($query);
//bind the name value to the placeholder in the template
$parameters = ["sunrise" => $sunrise, "sunset" => $sunset];
$statement->execute($parameters);
//call the function to build an array of the retrieved results
try {
$retrievedListings = Listing::storeSQLResultsInArray($statement);
} catch (Exception $exception) {
//rethrow the exception if retrieval failed
throw new PDOException($exception->getMessage(), 0, $exception);
}
return $retrievedListings;
}