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


PHP FrontendModel::getDB方法代码示例

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


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

示例1: loadDataGrid

 /**
  * Load the datagrid
  */
 private function loadDataGrid()
 {
     // create a new source-object
     $source = new SpoonDataGridSourceDB(FrontendModel::getDB(), array(FrontendMailmotorModel::QRY_DATAGRID_BROWSE_SENT, array('sent', FRONTEND_LANGUAGE)));
     // create datagrid
     $this->dataGrid = new SpoonDataGrid($source);
     $this->dataGrid->setCompileDirectory(FRONTEND_CACHE_PATH . '/compiled_templates');
     // set hidden columns
     $this->dataGrid->setColumnsHidden(array('id', 'status'));
     // set headers values
     $headers['name'] = SpoonFilter::ucfirst(FL::lbl('Name'));
     $headers['send_on'] = SpoonFilter::ucfirst(FL::lbl('Sent'));
     // set headers
     $this->dataGrid->setHeaderLabels($headers);
     // sorting columns
     $this->dataGrid->setSortingColumns(array('name', 'send_on'), 'name');
     $this->dataGrid->setSortParameter('desc');
     // set colum URLs
     $this->dataGrid->setColumnURL('name', FrontendNavigation::getURLForBlock('mailmotor', 'detail') . '/[id]');
     // set column functions
     $this->dataGrid->setColumnFunction(array('SpoonDate', 'getTimeAgo'), array('[send_on]'), 'send_on', true);
     // add styles
     $this->dataGrid->setColumnAttributes('name', array('class' => 'title'));
     // set paging limit
     $this->dataGrid->setPagingLimit(self::MAILINGS_PAGING_LIMIT);
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:29,代码来源:index.php

示例2: getData

    /**
     * Load the data, don't forget to validate the incoming data
     */
    private function getData()
    {
        // validate incoming parameters
        if ($this->URL->getParameter(1) === null) {
            $this->redirect(FrontendNavigation::getURL(404));
        }
        // fetch record
        $this->record = FrontendTagsModel::get($this->URL->getParameter(1));
        // validate record
        if (empty($this->record)) {
            $this->redirect(FrontendNavigation::getURL(404));
        }
        // fetch modules
        $this->modules = FrontendTagsModel::getModulesForTag($this->record['id']);
        // loop modules
        foreach ($this->modules as $module) {
            // set module class
            $class = 'Frontend' . SpoonFilter::toCamelCase($module) . 'Model';
            // get the ids of the items linked to the tag
            $otherIds = (array) FrontendModel::getDB()->getColumn('SELECT other_id
				 FROM modules_tags
				 WHERE module = ? AND tag_id = ?', array($module, $this->record['id']));
            // set module class
            $class = 'Frontend' . SpoonFilter::toCamelCase($module) . 'Model';
            // get the items that are linked to the tags
            $items = (array) FrontendTagsModel::callFromInterface($module, $class, 'getForTags', $otherIds);
            // add into results array
            if (!empty($items)) {
                $this->results[] = array('name' => $module, 'label' => FL::lbl(SpoonFilter::ucfirst($module)), 'items' => $items);
            }
        }
    }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:35,代码来源:detail.php

示例3: getQuestions

    /**
     * Get all items in a category
     *
     * @return	array
     * @param	int $categoryId			The id of the category.
     */
    public static function getQuestions($categoryId)
    {
        return (array) FrontendModel::getDB()->getRecords('SELECT i.*
															FROM faq_questions AS i
															WHERE i.category_id = ? AND i.language = ? AND i.hidden = ?
															ORDER BY i.sequence', array((int) $categoryId, FRONTEND_LANGUAGE, 'N'));
    }
开发者ID:netconstructor,项目名称:forkcms,代码行数:13,代码来源:model.php

示例4: buildCache

    /**
     * Build the language files
     *
     * @return	void
     * @param	string $language		The language to build the locale-file for.
     * @param	string $application		The application to build the locale-file for.
     */
    public static function buildCache($language, $application)
    {
        // get db
        $db = FrontendModel::getDB();
        // get types
        $types = $db->getEnumValues('locale', 'type');
        // get locale for backend
        $locale = (array) $db->getRecords('SELECT type, module, name, value
											FROM locale
											WHERE language = ? AND application = ?
											ORDER BY type ASC, name ASC, module ASC', array((string) $language, (string) $application));
        // start generating PHP
        $value = '<?php' . "\n";
        $value .= '/**' . "\n";
        $value .= ' *' . "\n";
        $value .= ' * This file is generated by Fork CMS, it contains' . "\n";
        $value .= ' * more information about the locale. Do NOT edit.' . "\n";
        $value .= ' * ' . "\n";
        $value .= ' * @author		Fork CMS' . "\n";
        $value .= ' * @generated	' . date('Y-m-d H:i:s') . "\n";
        $value .= ' */' . "\n";
        $value .= "\n";
        // loop types
        foreach ($types as $type) {
            // default module
            $modules = array('core');
            // continue output
            $value .= "\n";
            $value .= '// init var' . "\n";
            $value .= '$' . $type . ' = array();' . "\n";
            $value .= '$' . $type . '[\'core\'] = array();' . "\n";
            // loop locale
            foreach ($locale as $i => $item) {
                // types match
                if ($item['type'] == $type) {
                    // new module
                    if (!in_array($item['module'], $modules)) {
                        $value .= '$' . $type . '[\'' . $item['module'] . '\'] = array();' . "\n";
                        $modules[] = $item['module'];
                    }
                    // parse
                    if ($application == 'backend') {
                        $value .= '$' . $type . '[\'' . $item['module'] . '\'][\'' . $item['name'] . '\'] = \'' . str_replace('\\"', '"', addslashes($item['value'])) . '\';' . "\n";
                    } else {
                        $value .= '$' . $type . '[\'' . $item['name'] . '\'] = \'' . str_replace('\\"', '"', addslashes($item['value'])) . '\';' . "\n";
                    }
                    // unset
                    unset($locale[$i]);
                }
            }
        }
        // close php
        $value .= "\n";
        $value .= '?>';
        // store
        SpoonFile::setContent(constant(mb_strtoupper($application) . '_CACHE_PATH') . '/locale/' . $language . '.php', $value);
    }
开发者ID:netconstructor,项目名称:forkcms,代码行数:64,代码来源:language.php

示例5: getRelated

    /**
     * Get related "things" based on tags
     */
    private function getRelated()
    {
        // loop tags
        foreach ($this->tags as $tag) {
            // fetch entries
            $items = (array) FrontendModel::getDB()->getRecords('SELECT mt.module, mt.other_id
				 FROM modules_tags AS mt
				 INNER JOIN tags AS t ON t.id = mt.tag_id
				 WHERE t.language = ? AND t.tag = ?', array(FRONTEND_LANGUAGE, $tag));
            // loop items
            foreach ($items as $item) {
                // loop existing items
                foreach ($this->related as $related) {
                    // already exists
                    if ($item == $related) {
                        continue 2;
                    }
                }
                // add to list of related items
                $this->related[] = $item;
            }
        }
        // loop entries
        foreach ($this->related as $id => $entry) {
            // loop excluded records
            foreach ($this->exclude as $exclude) {
                // check if this entry should be excluded
                if ($entry['module'] == $exclude['module'] && $entry['other_id'] == $exclude['other_id']) {
                    unset($this->related[$id]);
                    continue 2;
                }
            }
            // set module class
            $class = 'Frontend' . SpoonFilter::toCamelCase($entry['module']) . 'Model';
            // get module record
            $this->related[$id] = FrontendTagsModel::callFromInterface($entry['module'], $class, 'getForTags', (array) array($entry['other_id']));
            if ($this->related[$id]) {
                $this->related[$id] = array_pop($this->related[$id]);
            }
            // remove empty items
            if (empty($this->related[$id])) {
                unset($this->related[$id]);
            }
        }
        // only show 3
        $this->related = array_splice($this->related, 0, 3);
    }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:50,代码来源:related.php

示例6: search

    /**
     * Parse the search results for this module
     *
     * Note: a module's search function should always:
     * 		- accept an array of entry id's
     * 		- return only the entries that are allowed to be displayed, with their array's index being the entry's id
     *
     * @return	array
     * @param	array $ids		The ids of the found results.
     */
    public static function search(array $ids)
    {
        // get db
        $db = FrontendModel::getDB();
        // define ids's to ignore
        $ignore = array(404);
        // get items
        $items = (array) $db->getRecords('SELECT p.id, p.title, m.url, p.revision_id AS text
											FROM pages AS p
											INNER JOIN meta AS m ON p.meta_id = m.id
											INNER JOIN pages_templates AS t ON p.template_id = t.id
											WHERE p.id IN (' . implode(', ', $ids) . ') AND p.id NOT IN (' . implode(', ', $ignore) . ') AND p.status = ? AND p.hidden = ? AND p.language = ?', array('active', 'N', FRONTEND_LANGUAGE), 'id');
        // prepare items for search
        foreach ($items as &$item) {
            $item['text'] = implode(' ', (array) $db->getColumn('SELECT pb.html
																	FROM pages_blocks AS pb
																	WHERE pb.revision_id = ? AND pb.status = ?', array($item['text'], 'active')));
            $item['full_url'] = FrontendNavigation::getURL($item['id']);
        }
        // return
        return $items;
    }
开发者ID:netconstructor,项目名称:forkcms,代码行数:32,代码来源:model.php

示例7: updateFeedback

    /**
     * Increase the number of views for this item
     *
     * @param int $id
     * @param bool $useful
     * @param mixed[optional] $previousFeedback
     * @return array
     */
    public static function updateFeedback($id, $useful, $previousFeedback = null)
    {
        // feedback hasn't changed so don't update the counters
        if ($previousFeedback !== null && $useful == $previousFeedback) {
            return;
        }
        $db = FrontendModel::getDB(true);
        // update counter with current feedback (increase)
        if ($useful) {
            $db->execute('UPDATE faq_questions
			 SET num_usefull_yes = num_usefull_yes + 1
			 WHERE id = ?', array((int) $id));
        } else {
            $db->execute('UPDATE faq_questions
			 SET num_usefull_no = num_usefull_no + 1
			 WHERE id = ?', array((int) $id));
        }
        // update counter with previous feedback (decrease)
        if ($previousFeedback) {
            $db->execute('UPDATE faq_questions
			 SET num_usefull_yes = num_usefull_yes - 1
			 WHERE id = ?', array((int) $id));
        } elseif ($previousFeedback !== null) {
            $db->execute('UPDATE faq_questions
			 SET num_usefull_no = num_usefull_no - 1
			 WHERE id = ?', array((int) $id));
        }
    }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:36,代码来源:model.php

示例8: getRelatedItemsByTags

    /**
     * Get all related items
     *
     * @param int $id The id of the item in the source-module.
     * @param int $module The source module.
     * @param int $otherModule The module wherein the related items should appear.
     * @param int[optional] $limit The maximum of related items to grab.
     * @return array
     */
    public static function getRelatedItemsByTags($id, $module, $otherModule, $limit = 5)
    {
        return (array) FrontendModel::getDB()->getColumn('SELECT t2.other_id
			 FROM modules_tags AS t
			 INNER JOIN modules_tags AS t2 ON t.tag_id = t2.tag_id
			 WHERE t.other_id = ? AND t.module = ? AND t2.module = ? AND (t2.module != t.module OR t2.other_id != t.other_id)
			 GROUP BY t2.other_id
			 ORDER BY COUNT(t2.tag_id) DESC
			 LIMIT ?', array((int) $id, (string) $module, (string) $otherModule, (int) $limit));
    }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:19,代码来源:model.php

示例9: get

    /**
     * Get an item.
     *
     * @param string $id The id of the item to fetch.
     * @return array
     */
    public static function get($id)
    {
        return (array) FrontendModel::getDB()->getRecord('SELECT i.*
			 FROM content_blocks AS i
			 WHERE i.id = ? AND i.status = ? AND i.hidden = ? AND i.language = ?', array((int) $id, 'active', 'N', FRONTEND_LANGUAGE));
    }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:12,代码来源:model.php

示例10: logout

 /**
  * Logout a profile.
  *
  * @return	void
  */
 public static function logout()
 {
     // delete session records
     FrontendModel::getDB(true)->delete('profiles_sessions', 'session_id = ?', array(SpoonSession::getSessionId()));
     // set is_logged_in to false
     SpoonSession::set('frontend_profile_logged_in', false);
     // delete cookie
     SpoonCookie::delete('frontend_profile_secret_key');
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:14,代码来源:authentication.php

示例11: loadProfile

    /**
     * Load a user profile by id.
     *
     * @return	void
     * @param	int $id		Profile id to load.
     */
    private function loadProfile($id)
    {
        // get profile data
        $profileData = (array) FrontendModel::getDB()->getRecord('SELECT p.id, p.email, p.status, p.display_name, UNIX_TIMESTAMP(p.registered_on) AS registered_on
																	FROM profiles AS p
																	WHERE p.id = ?', (int) $id);
        // set properties
        $this->setId($profileData['id']);
        $this->setEmail($profileData['email']);
        $this->setStatus($profileData['status']);
        $this->setDisplayName($profileData['display_name']);
        $this->setRegisteredOn($profileData['registered_on']);
        // get the groups (only the ones we still have access to)
        $this->groups = (array) FrontendModel::getDB()->getPairs('SELECT pg.id, pg.name
																FROM profiles_groups AS pg
																INNER JOIN profiles_groups_rights AS pgr ON pg.id = pgr.group_id
																WHERE pgr.profile_id = :id AND (pgr.expires_on IS NULL OR pgr.expires_on >= NOW())', array(':id' => (int) $id));
    }
开发者ID:netconstructor,项目名称:forkcms,代码行数:24,代码来源:profile.php

示例12: unsubscribe

 /**
  * Unsubscribes an e-mail address from CampaignMonitor and our database
  *
  * @param string $email The e-mail address to unsubscribe.
  * @param string[optional] $groupId The id of the group to unsubscribe from.
  * @return bool
  */
 public static function unsubscribe($email, $groupId = null)
 {
     // get objects
     $db = FrontendModel::getDB(true);
     $cm = self::getCM();
     // set group ID
     $groupId = !empty($groupId) ? $groupId : FrontendMailmotorModel::getDefaultGroupID();
     // get group CM ID
     $groupCMId = self::getCampaignMonitorID('list', $groupId);
     // group exists
     if (FrontendMailmotorModel::existsGroup($groupId)) {
         try {
             // unsubscribe the email from this group
             $cm->unsubscribe($email, $groupCMId);
         } catch (Exception $e) {
             // stop here if something went wrong with CM
             return false;
         }
         // set variables
         $subscriber['status'] = 'unsubscribed';
         $subscriber['unsubscribed_on'] = FrontendModel::getUTCDate('Y-m-d H:i:s');
         // unsubscribe the user
         $db->update('mailmotor_addresses_groups', $subscriber, 'email = ? AND group_id = ?', array($email, $groupId));
         // user unsubscribed
         return true;
     }
     // user not unsubscribed
     return false;
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:36,代码来源:helper.php

示例13: insertDataField

 /**
  * Insert data fields.
  *
  * @param array $data The data to insert.
  * @return int
  */
 public static function insertDataField(array $data)
 {
     return FrontendModel::getDB(true)->insert('forms_data_fields', $data);
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:10,代码来源:model.php

示例14: loadUser

    /**
     * Load the data for the given user
     *
     * @return	void
     * @param	int $userId		The users id in the backend.
     */
    public function loadUser($userId)
    {
        // redefine
        $userId = (int) $userId;
        // get database instance
        $db = FrontendModel::getDB();
        // get user-data
        $userData = (array) $db->getRecord('SELECT u.id, u.email
											FROM users AS u
											WHERE u.id = ?
											LIMIT 1', array($userId));
        // if there is no data we have to destroy this object, I know this isn't a realistic situation
        if (empty($userData)) {
            throw new FrontendException('The user (' . $userId . ') doesn\'t exist.');
        }
        // set properties
        $this->setUserId($userData['id']);
        $this->setEmail($userData['email']);
        // get settings
        $settings = (array) $db->getPairs('SELECT us.name, us.value
											FROM users_settings AS us
											WHERE us.user_id = ?', array($userId));
        // loop settings and store them in the object
        foreach ($settings as $key => $value) {
            $this->settings[$key] = unserialize($value);
        }
    }
开发者ID:netconstructor,项目名称:forkcms,代码行数:33,代码来源:user.php

示例15: getAll

    /**
     * Get all items
     *
     * @return	array
     */
    public static function getAll()
    {
        return (array) FrontendModel::getDB()->getRecords('SELECT *
															FROM location
															WHERE language = ?', array(FRONTEND_LANGUAGE));
    }
开发者ID:netconstructor,项目名称:forkcms,代码行数:11,代码来源:model.php


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