本文整理汇总了PHP中dmDb::query方法的典型用法代码示例。如果您正苦于以下问题:PHP dmDb::query方法的具体用法?PHP dmDb::query怎么用?PHP dmDb::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dmDb
的用法示例。
在下文中一共展示了dmDb::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFirstMedia
public function getFirstMedia()
{
if ($this->_invoker->contains($this->_options['mediaAlias'])) {
return $this->_invoker->reference($this->_options['mediaAlias'])->getFirst();
}
return dmDb::query('DmMedia m, m.Folder f, m.' . $this->getGalleryRelClass() . ' rel')->where('rel.dm_record_id = ?', $this->_invoker->get('id'))->orderBy('rel.position ASC')->select('m.*, f.*')->fetchOne();
}
示例2: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
throw new dmException('deprecated');
$this->withDatabase();
$page = dmDb::table('DmPage')->findOneByIdWithI18n($arguments['id'], $arguments['culture']);
if (!$page instanceof DmPage) {
throw new dmException('No page with id = ' . $arguments['id']);
}
$this->getContext()->setPage($page);
$area = dmDb::query('DmArea a, a.Zones z, z.Widgets w')->select('a.id, z.id, w.module, w.action, w.value')->where('a.type = ? AND a.dm_page_view_id = ?', array('content', $page->get('PageView')->get('id')))->orderBy('z.position asc, w.position asc')->fetchArray();
$widgetTypeManager = $dmContext->get('widget_type_manager');
$html = '';
foreach ($area[0]['Zones'] as $zone) {
foreach ($zone['Widgets'] as $widget) {
if (!in_array($widget['module'] . '.' . $widget['action'], self::$skipWidgets)) {
$widget['css_class'] = null;
$widgetViewClass = $widgetTypeManager->getWidgetType($widget['module'], $widget['action'])->getViewClass();
$widgetView = new $widgetViewClass($widget);
try {
$html .= $widgetView->toIndexableString();
} catch (Exception $e) {
$this->log($e->getMessage());
}
}
}
}
$indexableText = dmSearchIndex::cleanText($html);
die($indexableText);
}
示例3: updateDatabase
/**
* Update changed documentation pages in database
*/
protected function updateDatabase($branch)
{
$types = dmDb::query('Doc d')->select('d.type')->distinct()->fetchFlat();
$cultures = sfConfig::get('dm_i18n_cultures');
$originalCulture = sfDoctrineRecord::getDefaultCulture();
foreach ($types as $type) {
foreach ($cultures as $culture) {
sfDoctrineRecord::setDefaultCulture($culture);
$dir = dmOs::join($this->repo->getDir(), $type, $culture);
$files = sfFinder::type('file')->name('/^\\d{2}\\s-\\s.+\\.markdown$/')->in($dir);
foreach ($files as $file) {
$docName = preg_replace('/^\\d{2}\\s-\\s(.+)\\.markdown$/', '$1', basename($file));
$docRecord = dmDb::query('DocPage dp')->withI18n()->innerJoin('dp.Doc doc')->innerJoin('doc.Branch branch')->where('branch.number = ?', $branch)->andWhere('doc.type = ?', $type)->andWhere('dpTranslation.name = ?', $docName)->fetchOne();
if ($docRecord) {
$docText = file_get_contents($file);
if ($docRecord->text != $docText) {
$docRecord->text = $docText;
$docRecord->save();
}
}
}
}
}
sfDoctrineRecord::setDefaultCulture($originalCulture);
}
示例4: generateLayoutTemplates
protected function generateLayoutTemplates()
{
$this->logSection('diem', 'generate layout templates');
$filesystem = $this->get('filesystem');
foreach (dmDb::query('DmLayout l')->fetchRecords() as $layout) {
$template = $layout->get('template');
$templateFile = dmProject::rootify('apps/front/modules/dmFront/templates/' . $template . 'Success.php');
if (!file_exists($templateFile)) {
if ($filesystem->mkdir(dirname($templateFile))) {
$filesystem->copy(dmOs::join(sfConfig::get('dm_front_dir'), 'modules/dmFront/templates/pageSuccess.php'), $templateFile);
$filesystem->chmod($templateFile, 0777);
} else {
$this->logBlock('Can NOT create layout template ' . $template, 'ERROR');
}
}
}
$layoutFile = dmProject::rootify('apps/front/modules/dmFront/templates/layout.php');
if (!file_exists($layoutFile)) {
if ($filesystem->mkdir(dirname($layoutFile))) {
$filesystem->copy(dmOs::join(sfConfig::get('dm_front_dir'), 'modules/dmFront/templates/layout.php'), $layoutFile);
$filesystem->chmod($layoutFile, 0777);
} else {
$this->logBlock('Can NOT create layout ' . $layoutFile, 'ERROR');
}
}
}
示例5: getGroupNames
public function getGroupNames()
{
$groups = dmDb::query('DmSetting s')->select('s.group_name')->groupBy('s.group_name')->fetchPDO();
foreach ($groups as $index => $group) {
$groups[$index] = $group[0];
}
return $groups;
}
示例6: executeTest
public function executeTest()
{
$widget = dmDb::query('DmWidget q')->withI18n()->where('q.id = ?', 272)->fetchOne();
$widgetValue = $widget->value;
$widget = $widget->toArray();
$widget['value'] = $widgetValue;
$this->html = $this->getService('page_helper')->renderWidget($widget);
}
示例7: getUser
public function getUser()
{
$userId = $this->get('user_id');
if (!isset(self::$usersCache[$userId])) {
self::$usersCache[$userId] = $userId ? dmDb::query('DmUser u')->where('u.id = ?', $userId)->fetchRecord() : null;
}
return self::$usersCache[$userId];
}
示例8: executeShow
public function executeShow()
{
$query = $this->getShowQuery('b');
$this->branch = $this->getRecord($query);
$this->tuto = dmDb::query('DocPage p')->withI18n()->leftJoin('p.Doc d')->where('d.type = ?', 'tuto')->orderBy('p.position ASC')->fetchOne();
$this->howTo = dmDb::query('Doc d')->withI18n()->where('d.type = ?', 'howto')->fetchOne();
$this->openSourceProjects = dmDb::query('DocPage p')->withI18n()->where('pTranslation.name = ?', 'Open source projects')->fetchOne();
}
示例9: createAdminUser
protected function createAdminUser()
{
dmDb::query('DmUser u')->delete()->where('u.username = ?', 'admin')->execute();
$user = dmDb::table('DmUser')->create(array('username' => 'admin', 'email' => 'demo@nomail.org', 'is_active' => true, 'is_super_admin' => false));
$user->setPassword('admin');
$user->addGroupByName('demo');
$user->save();
}
示例10: getNbPages
/**
* How many pages use this layout?
*/
public function getNbPages()
{
$nb = 0;
foreach ($this->get('PageViews') as $pageView) {
$nb += dmDb::query('DmPage p')->where('p.module = ?', $pageView->module)->andWhere('p.action = ?', $pageView->action)->count();
}
return $nb;
}
示例11: setTemplate
/**
* Set a template to the mail
*
* @param mixed $templateName the template name, or a DmMailTemplateInstance
* @return dmMail $this
*/
public function setTemplate($templateName)
{
if ($templateName instanceof DmMailTemplate) {
$this->template = $templateName;
} elseif (!($this->template = dmDb::query('DmMailTemplate t')->where('t.name = ?', $templateName)->fetchRecord())) {
$this->template = dmDb::create('DmMailTemplate', array('name' => $templateName));
}
return $this;
}
示例12: getParentChoices
protected function getParentChoices()
{
$_parentChoices = dmDb::query('DmMediaFolder f')->where('f.lft < ? OR f.rgt > ?', array($this->folder->lft, $this->folder->rgt))->orderBy('f.lft')->select('f.id, f.level, f.rel_path')->fetchPDO();
$parentChoices = array();
foreach ($_parentChoices as $values) {
$name = basename($values[2]) ? basename($values[2]) : 'root';
$parentChoices[$values[0]] = str_repeat(' ', $values[1]) . '- ' . $name;
}
return $parentChoices;
}
示例13: executeGetAttributes
public function executeGetAttributes(sfWebRequest $request)
{
$bm = $this->getService('behaviors_manager');
$user = $this->getService('user');
$this->forward404Unless($zone = dmDb::query('DmZone z')->where('z.id = ?', $request->getParameter('zone_id'))->select('z.width as width, z.css_class as css_class')->limit(1)->fetchPDO());
if ($bm->isZoneAttachable() && ($user->can('behavior_add') || $user->can('behavior_edit') || $user->can('behavior_delete') || $user->can('behavior_sort'))) {
$zone[0][1] = $zone[0][1] . '.dm_behaviors_attachable';
}
return $this->renderJson($zone[0]);
}
示例14: getFolderChoices
protected function getFolderChoices()
{
$_folderChoices = dmDb::query('DmMediaFolder f')->orderBy('f.lft')->select('f.id, f.level, f.rel_path')->fetchPDO();
$folderChoices = array();
foreach ($_folderChoices as $values) {
$name = basename($values[2]) ? basename($values[2]) : 'root';
$folderChoices[$values[0]] = str_repeat(' ', $values[1]) . '- ' . $name;
}
return $folderChoices;
}
示例15: executeMyAccount
public function executeMyAccount()
{
if ($this->user = $this->getUser()->getDmUser()) {
$this->plugins = dmDb::query('Plugin p')->where('p.created_by = ?', $this->user->id)->andWhere('p.is_active = ?', true)->orderByPosition()->fetchRecords();
$this->preloadPages($this->plugins);
} else {
$this->form = $this->forms['DmSigninFront'] = new DmSigninFrontForm();
unset($this->form['remember_me']);
}
}