本文整理汇总了PHP中Illuminate\Database\Capsule\Manager::getPdo方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::getPdo方法的具体用法?PHP Manager::getPdo怎么用?PHP Manager::getPdo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Capsule\Manager
的用法示例。
在下文中一共展示了Manager::getPdo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: seedTemplates
public function seedTemplates()
{
$css = '';
$js = '';
$dir = new DirectoryIterator($this->app['base_dir'] . '/templates');
foreach ($dir as $item) {
if ($item->isDir() && !$item->isDot()) {
$name = $this->nameFromPath($item->getRealPath());
//check if template doesn't already exist in db
$template = DB::table('templates')->where('name', $name)->first();
if (!$template) {
//if no config file exists for template continue
if (!file_exists($item->getRealPath() . '/config.php')) {
continue;
}
$config = (require $item->getRealPath() . '/config.php');
//create a new template in db
DB::table('templates')->insert(array('name' => $config['name'], 'color' => $config['color'], 'category' => $config['category'], 'thumbnail' => 'templates/' . strtolower(str_replace(' ', '-', $config['name'])) . '/thumbnail.png'));
$id = DB::getPdo()->lastInsertId();
//get css
if (file_exists($item->getRealPath() . '/css/styles.css')) {
$css = file_get_contents($item->getRealPath() . '/css/styles.css');
}
//get js
if (file_exists($item->getRealPath() . '/js/scripts.js')) {
$js = file_get_contents($item->getRealPath() . '/js/scripts.js');
}
//loop trough all .html files and create a page in db for each one
$items = new \DirectoryIterator($item->getRealPath());
foreach ($items as $file) {
if (pathinfo($file->getFilename(), PATHINFO_EXTENSION) === 'html') {
DB::table('pages')->insert(array('name' => str_replace('.' . pathinfo($file->getFilename(), PATHINFO_EXTENSION), '', $file->getFileName()), 'html' => file_get_contents($file->getRealPath()), 'css' => $css, 'js' => $js, 'libraries' => isset($config['libraries']) ? json_encode($config['libraries']) : '', 'theme' => isset($config['theme']) ? $config['theme'] : 'default', 'pageable_id' => $id, 'pageable_type' => 'Template'));
}
}
}
}
}
}