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