当前位置: 首页>>代码示例>>PHP>>正文


PHP Listing::ngToDateTime方法代码示例

本文整理汇总了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;
 }
开发者ID:brbrown59,项目名称:bread-basket,代码行数:43,代码来源:listing.php


注:本文中的Listing::ngToDateTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。