本文整理汇总了PHP中Application::db方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::db方法的具体用法?PHP Application::db怎么用?PHP Application::db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application::db方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($files)
{
$categories = [];
$files = $files->get_all();
$cat = '';
foreach ($files as $file) {
if ($file['type'] != 'post') {
continue;
}
if (is_array($file['categories'])) {
foreach ($file['categories'] as $cat) {
if (!array_key_exists($cat, $categories)) {
$categories[$cat] = [];
}
$categories[$cat][] = $file;
}
} else {
$cat = $file['categories'];
if (!array_key_exists($cat, $categories)) {
$categories[$cat] = [];
}
$categories[$cat][] = $file;
}
}
Application::db()->store('categories_list', $categories);
}
示例2: execute
public function execute($files)
{
$posts = $files->filter_by(array(&$this, 'filter_by_type'));
$fixed_posts = [];
foreach ($posts as $post) {
$fixed_posts[(int) format_date_YYYYMMDD($post['file'])] = $post;
}
krsort($fixed_posts);
Application::db()->store('post_list', $fixed_posts);
}
示例3: run
public static function run($configFile, $applicationEnv)
{
Loader::registerAutoload();
self::$request = new Request();
self::$response = new Response();
include $configFile;
self::$config = $config[$applicationEnv];
StringHelper::setCryptKey(self::$config['crypt_key']);
self::$db = new Db(self::$config['db']['params']);
self::initView();
self::startDispatch();
}
示例4: connect
public static function connect()
{
// parse json config
$config_file = file_get_contents('config/config.json');
$config = json_decode($config_file, true);
// create a new pdo connection
self::$db = new PDO('mysql:host=' . $config['database']['db_host'] . ';dbname=' . $config['database']['db_name'] . ';charset=utf8', $config['database']['db_user'], $config['database']['db_pass'], array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
// update the connection count
self::$connection_count++;
// return the db instance
return self::$db;
}
示例5: execute
/**
* Make the database from the loaded content.
* @param $files Files | The Files component.
* @return void
*/
public function execute($files)
{
$files = $files->filter_by(array(&$this, 'filter_by_type'));
Application::db()->store('page_list', $files);
}