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


PHP AppCore::getDatabaseConnection方法代码示例

本文整理汇总了PHP中Railpage\AppCore::getDatabaseConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP AppCore::getDatabaseConnection方法的具体用法?PHP AppCore::getDatabaseConnection怎么用?PHP AppCore::getDatabaseConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Railpage\AppCore的用法示例。


在下文中一共展示了AppCore::getDatabaseConnection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fetchLocomotive

 /**
  * Fetch locomotive data from Memcached/Redis/Database
  * @since Version 3.9.1
  * @param \Railpage\Locos\Locomotive $Loco
  * @return array
  */
 public static function fetchLocomotive(Locomotive $Loco)
 {
     $AppCore = new AppCore();
     $Memcached = AppCore::getMemcached();
     $Database = $AppCore->getDatabaseConnection();
     if (!($row = $Memcached->fetch($Loco->mckey))) {
         $timer = Debug::getTimer();
         $query = "SELECT l.*, s.name AS loco_status, ow.operator_name AS owner_name, op.operator_name AS operator_name\n                        FROM loco_unit AS l\n                        LEFT JOIN loco_status AS s ON l.loco_status_id = s.id\n                        LEFT JOIN operators AS ow ON ow.operator_id = l.owner_id\n                        LEFT JOIN operators AS op ON op.operator_id = l.operator_id\n                        WHERE l.loco_id = ?";
         $row = $Database->fetchRow($query, $Loco->id);
         Debug::logEvent("Zend_DB: Fetch loco ID", $timer);
         $Memcached->save($Loco->mckey, $row, strtotime("+1 year"));
     }
     return $row;
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:20,代码来源:LocomotiveUtility.php


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