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


PHP Database::getInstance方法代码示例

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


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

示例1: setupTemplate

 protected function setupTemplate()
 {
     global $cfg;
     parent::setupTemplate();
     $db = Database::getInstance($cfg['DPS']['dsn']);
     $auth = Auth::getInstance();
     $userID = $auth->getUserID();
     $audioID = pg_escape_string($this->fieldData['audioID']);
     $sql = "SELECT jinglepkgid FROM audiojinglepkgs WHERE audioid = {$audioID}";
     $jinglepkgID = $db->getOne($sql);
     $sql = "SELECT name FROM jinglepkgs WHERE id = {$jinglepkgID}";
     $currentpkg = $db->getOne($sql);
     if ($currentpkg == '') {
         $currentpkg = 'Default';
     }
     $sql = "SELECT title FROM audio WHERE id = {$audioID}";
     $jinglename = $db->getOne($sql);
     $sql = "SELECT name, id FROM jinglepkgs";
     $jinglepkgs = $db->getAll($sql);
     $this->assign('access_playlist', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 33), $userID));
     $this->assign('access_sue', AuthUtil::getDetailedUserrealmAccess(array(24, 20, 3), $userID));
     $this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
     $this->assign('jinglepkgs', $jinglepkgs);
     $this->assign('currentpkg', $currentpkg);
     $this->assign('currentpkgid', $jinglepkgID);
     $this->assign('jinglename', $jinglename);
     $this->assign('jingleID', $audioID);
 }
开发者ID:radiowarwick,项目名称:digiplay_legacy,代码行数:28,代码来源:DPSStationMoveJingleViewer.class.php

示例2: __construct

 function __construct()
 {
     parent::__construct();
     $this->setTitle(sprintf(Messages::getString('EnterDataPage.Title'), $this->project->getName()));
     $this->menu = array(Messages::getString('General.AdminMenu') => "admin.php") + $this->menu;
     $this->db = Database::getInstance();
 }
开发者ID:BackupTheBerlios,项目名称:reson-svn,代码行数:7,代码来源:EnterDataPage.php

示例3: sfCategory

 /**
  * constructor
  */
 function sfCategory($id = null)
 {
     $this->db =& Database::getInstance();
     $this->initVar("categoryid", XOBJ_DTYPE_INT, null, false);
     $this->initVar("parentid", XOBJ_DTYPE_INT, null, false);
     $this->initVar("name", XOBJ_DTYPE_TXTBOX, null, true, 100);
     $this->initVar("description", XOBJ_DTYPE_TXTAREA, null, false, 255);
     $this->initVar("total", XOBJ_DTYPE_INT, 1, false);
     $this->initVar("weight", XOBJ_DTYPE_INT, 1, false);
     $this->initVar("created", XOBJ_DTYPE_INT, null, false);
     $this->initVar("last_faq", XOBJ_DTYPE_INT);
     //not persistent values
     $this->initVar("faqcount", XOBJ_DTYPE_INT, 0, false);
     $this->initVar('last_faqid', XOBJ_DTYPE_INT);
     $this->initVar('last_question_link', XOBJ_DTYPE_TXTBOX);
     if (isset($id)) {
         if (is_array($id)) {
             $this->assignVars($id);
         } else {
             $category_handler = new sfCategoryHandler($this->db);
             $category =& $category_handler->get($id);
             foreach ($category->vars as $k => $v) {
                 $this->assignVar($k, $v['value']);
             }
             $this->assignOtherProperties();
         }
     }
 }
开发者ID:trabisdementia,项目名称:xuups,代码行数:31,代码来源:category.php

示例4: getConfiguration

 public function getConfiguration($param)
 {
     $dc = Database::getInstance();
     $obj = $dc->prepare('SELECT * FROM tl_rs_settings ORDER BY have_license,language, language_demo ASC')->execute()->fetchAllAssoc();
     $returner = array();
     $error = true;
     $edit_link = '<a href="contao/main.php?do=readspeaker_settings&act=edit&id=%s&amp;rt=%s&ref=%s" title="" class="edit"><img src="system/themes/default/images/edit.gif" width="12" height="16" alt="Edit "></a>';
     if (count($obj) >= 1) {
         $error = false;
         foreach ($obj as $key => $row) {
             if ($row['have_license']) {
                 $returner['ID: ' . $row['customer_id']][$row['id']] = $GLOBALS['TL_LANG']['MSC']['rs_language_codes'][$row['language']] . ' ' . ($row['domain'] ? '[' . $row['domain'] . ']' : '');
                 // . ' ' . ($row['note'] ? '<span class="tl_blue" >[' . $row['note'] . ']</span>' : '');
             } else {
                 $returner['DEMO'][$row['id']] = $GLOBALS['TL_LANG']['MSC']['rs_language_codes'][$row['language_demo']] . ' ' . ($row['domain'] ? '[' . $row['domain'] . ']' : '');
                 // . ' ' . ($row['note'] ? '<span class="tl_blue" >[' . $row['note'] . ']</span>' : '');
             }
         }
     }
     if ($error) {
         $session = $this->Session->get('referer');
         $session[TL_REFERER_ID]['current'] = substr(\Environment::get('requestUri'), strlen(TL_PATH) + 1);
         $this->Session->set('referer', $session);
         Message::addRaw(sprintf($GLOBALS['TL_LANG']['tl_module']['error']['error_no_settings'], REQUEST_TOKEN, TL_REFERER_ID));
     }
     return $returner;
 }
开发者ID:joeherold,项目名称:readspeaker,代码行数:27,代码来源:tl_module.php

示例5: run

 public function run($blnInstalled)
 {
     $this->db = \Database::getInstance();
     if ($blnInstalled) {
         $this->convertSerializedValues();
     }
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:7,代码来源:To0020030009.php

示例6: hookGetUserNavigation

 /**
  * @param array $navigation
  * @param       $showAll
  *
  * @return array
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public static function hookGetUserNavigation(array $navigation, $showAll)
 {
     if (TL_MODE == 'BE') {
         try {
             if (!$showAll) {
                 $database = \Database::getInstance();
                 if ($database->tableExists('orm_avisota_message_category')) {
                     $category = Helper::resolveCategoryFromInput();
                     if ($category) {
                         $foundCustomEntry = false;
                         $menu =& $navigation['avisota'];
                         foreach ($menu['modules'] as $name => &$module) {
                             if ($name == 'avisota_category_' . $category->getId()) {
                                 $module['class'] .= ' active';
                                 $foundCustomEntry = true;
                             }
                         }
                         if ($foundCustomEntry) {
                             $classes = explode(' ', $menu['modules']['avisota_newsletter']['class']);
                             $classes = array_map('trim', $classes);
                             $pos = array_search('active', $classes);
                             if ($pos !== false) {
                                 unset($classes[$pos]);
                             }
                             $menu['modules']['avisota_newsletter']['class'] = implode(' ', $classes);
                         }
                     }
                 }
             }
         } catch (\Exception $exception) {
             // silently ignore
         }
     }
     return $navigation;
 }
开发者ID:avisota,项目名称:contao-message,代码行数:42,代码来源:CustomMenu.php

示例7: getArticleOptions

    public function getArticleOptions(CreateOptionsEvent $event)
    {
        \Controller::loadLanguageFile('tl_article');
        $database = \Database::getInstance();
        $dataContainer = $event->getDataContainer();
        $options = $event->getOptions();
        // add articles in this page to options array
        $resultSet = $database->prepare('SELECT a.id, a.title, a.inColumn
				 FROM tl_article a
				 INNER JOIN tl_article b
				 ON a.pid = b.pid
				 INNER JOIN tl_content c
				 ON c.pid = b.id
				 WHERE c.id = ?
				 ORDER BY a.inColumn, a.sorting')->execute($dataContainer->id);
        while ($resultSet->next()) {
            if (isset($GLOBALS['TL_LANG']['tl_article'][$resultSet->inColumn])) {
                $sectionName = $GLOBALS['TL_LANG']['tl_article'][$resultSet->inColumn];
            } else {
                $sectionName = $resultSet->inColumn;
            }
            if (isset($GLOBALS['TL_LANG']['tl_article'][$sectionName])) {
                $sectionName = $GLOBALS['TL_LANG']['tl_article'][$sectionName];
            }
            $options[$sectionName][$resultSet->id] = $resultSet->title;
        }
    }
开发者ID:bit3,项目名称:contao-toc-element,代码行数:27,代码来源:OptionsBuilder.php

示例8: getTypeOfAttribute

 /**
  * Retrieve the type name from an attribute.
  *
  * @param int $value The id of an attribute.
  *
  * @return string
  */
 public function getTypeOfAttribute($value)
 {
     if (!isset(self::$attributeTypes[$value])) {
         self::$attributeTypes[$value] = \Database::getInstance()->prepare('SELECT type FROM tl_metamodel_attribute WHERE id=?')->limit(1)->execute($value)->type;
     }
     return self::$attributeTypes[$value];
 }
开发者ID:zonky2,项目名称:core,代码行数:14,代码来源:RenderSettingAttributeIs.php

示例9: login

function login($email, $password)
{
    $db = Database::getInstance();
    $mysqli = $db->getConnection();
    $mysqli->query("SET NAMES utf8");
    $sql_query = 'SELECT * FROM user WHERE email="' . $email . '"';
    $result = $mysqli->query($sql_query);
    $user = mysqli_fetch_assoc($result);
    global $password;
    //if password correct
    if (password_verify($password, $user['password'])) {
        session_start();
        $_SESSION['auth'] = true;
        $_SESSION['id'] = $user['id'];
        $_SESSION['user'] = $user['user'];
        //check keep login, set coockie
        if ($_POST['loginkeeping'] == "on") {
            $key = md5(generate(7, 15));
            setcookie('login', $user['user'], time() + 60 * 60 * 24 * 365);
            setcookie('key', $key, time() + 60 * 60 * 24 * 365);
            $sql_query = "UPDATE user SET cookie='" . $key . "' WHERE id='" . $user['id'] . "'";
            $mysqli->query($sql_query);
            //if no keep login, set cookie as NULL
        } else {
            $sql_query = "UPDATE user SET cookie=NULL WHERE id='" . $user['id'] . "'";
            $mysqli->query($sql_query);
        }
        header("Location: http://" . $_SERVER['SERVER_NAME']);
    } else {
        echo "Email or password is incorrect";
    }
}
开发者ID:Hydropericardium,项目名称:blog.dev,代码行数:32,代码来源:generate.php

示例10: doesUserHasAccess

 public static function doesUserHasAccess($moduleName, $userId, $accessType)
 {
     try {
         $db = Database::getInstance();
         $conn = $db->getConnection();
         $stmt = $conn->prepare("SELECT `isSuperUser` FROM `usermaster` WHERE `userId` =:userId");
         $stmt->bindParam(':userId', $userId, PDO::PARAM_STR);
         $stmt->execute();
         $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
         $isSuperUser = $result[0]['isSuperUser'];
         if ($isSuperUser) {
             return true;
         }
         $stmt = $conn->prepare("SELECT * FROM `roleaccesspermission` WHERE `accessId` IN (SELECT `accessId` FROM `accesspermission` WHERE `ModuleName`=:moduleName AND `accessType`=:accessType) AND `roleId` IN (SELECT `roleId` FROM `userroleinfo` WHERE `userId`=:userId)");
         $stmt->bindParam(':moduleName', $moduleName, PDO::PARAM_STR);
         $stmt->bindParam(':userId', $userId, PDO::PARAM_STR);
         $stmt->bindParam(':accessType', $accessType, PDO::PARAM_STR);
         if ($stmt->execute()) {
             $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
             if (count($result) > 0) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } catch (Exception $e) {
         return false;
     }
     return false;
 }
开发者ID:incizon,项目名称:HicreteWebApp,代码行数:32,代码来源:appUtil.php

示例11: addButton

 /**
  * @param GetEditModeButtonsEvent $objEvent
  */
 public function addButton(GetEditModeButtonsEvent $objEvent)
 {
     if (!$this->isRightContext($objEvent->getEnvironment())) {
         return;
     }
     // Check the file cache.
     $strInitFilePath = '/system/config/initconfig.php';
     if (file_exists(TL_ROOT . $strInitFilePath)) {
         $strFile = new \File($strInitFilePath);
         $arrFileContent = $strFile->getContentAsArray();
         foreach ($arrFileContent as $strContent) {
             if (!preg_match("/(\\/\\*|\\*|\\*\\/|\\/\\/)/", $strContent)) {
                 //system/tmp.
                 if (preg_match("/system\\/tmp/", $strContent)) {
                     // Set data.
                     \Message::addInfo($GLOBALS['TL_LANG']['MSC']['disabled_cache']);
                 }
             }
         }
     }
     // Update a field with last sync information
     $objSyncTime = \Database::getInstance()->prepare("SELECT cl.syncFrom_tstamp as syncFrom_tstamp, user.name as syncFrom_user, user.username as syncFrom_alias\n                         FROM tl_synccto_clients as cl\n                         INNER JOIN tl_user as user\n                         ON cl.syncTo_user = user.id\n                         WHERE cl.id = ?")->limit(1)->execute(\Input::get("id"));
     if ($objSyncTime->syncFrom_tstamp != 0 && strlen($objSyncTime->syncFrom_user) != 0 && strlen($objSyncTime->syncFrom_alias) != 0) {
         $strLastSync = vsprintf($GLOBALS['TL_LANG']['MSC']['last_sync'], array(date($GLOBALS['TL_CONFIG']['timeFormat'], $objSyncTime->syncFrom_tstamp), date($GLOBALS['TL_CONFIG']['dateFormat'], $objSyncTime->syncFrom_tstamp), $objSyncTime->syncFrom_user, $objSyncTime->syncFrom_alias));
         // Set data
         \Message::addInfo($strLastSync);
     }
     // Set buttons.
     $objEvent->setButtons(array('start_sync' => '<input type="submit" name="start_sync" id="start_sync" class="tl_submit" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['sync']) . '" />', 'start_sync_all' => '<input type="submit" name="start_sync_all" id="start_sync_all" class="tl_submit" accesskey="o" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['syncAll']) . '" />'));
 }
开发者ID:menatwork,项目名称:synccto,代码行数:33,代码来源:From.php

示例12: createActivityList

 function createActivityList()
 {
     $db = Database::getInstance();
     $cxn = $db->getConnection();
     if ($this->activityid == '') {
         $query = "SELECT * FROM Activity";
     } else {
         if (in_array($this->activityid, $this->production)) {
             $query = "SELECT * FROM Activity WHERE Activity_ID IN(1,2,3,16)";
         } else {
             if (in_array($this->activityid, $this->nonproduction)) {
                 $query = "SELECT * FROM Activity WHERE Activity_ID IN(4,8,9,11,12)";
             }
         }
     }
     //			print("$query<br>");
     if (!($res = $cxn->query($query))) {
         echo "error :", $cxn->error;
     } else {
         $rows = array();
         while ($r = mysqli_fetch_assoc($res)) {
             $rows[] = $r;
         }
         $this->activitylist = json_encode($rows);
     }
 }
开发者ID:sknagesh,项目名称:divyaeng2,代码行数:26,代码来源:class.Activity.php

示例13: findProducts

 /**
  * Fill the object's arrProducts array
  *
  * @param array|null $arrCacheIds
  *
  * @return array
  */
 protected function findProducts($arrCacheIds = null)
 {
     $t = Product::getTable();
     $arrColumns = array();
     $arrCategories = $this->findCategories();
     $arrProductIds = \Database::getInstance()->query("\n                SELECT pid\n                FROM tl_iso_product_category\n                WHERE page_id IN (" . implode(',', $arrCategories) . ")\n            ")->fetchEach('pid');
     $arrTypes = \Database::getInstance()->query("SELECT id FROM tl_iso_producttype WHERE variants='1'")->fetchEach('id');
     if (empty($arrProductIds)) {
         return array();
     }
     $queryBuilder = new FilterQueryBuilder(Isotope::getRequestCache()->getFiltersForModules($this->iso_filterModules));
     $arrColumns[] = "(\n            ({$t}.id IN (" . implode(',', $arrProductIds) . ") AND {$t}.type NOT IN (" . implode(',', $arrTypes) . "))\n            OR {$t}.pid IN (" . implode(',', $arrProductIds) . ")\n        )";
     if (!empty($arrCacheIds) && is_array($arrCacheIds)) {
         $arrColumns[] = Product::getTable() . ".id IN (" . implode(',', $arrCacheIds) . ")";
     }
     // Apply new/old product filter
     if ($this->iso_newFilter == 'show_new') {
         $arrColumns[] = Product::getTable() . ".dateAdded>=" . Isotope::getConfig()->getNewProductLimit();
     } elseif ($this->iso_newFilter == 'show_old') {
         $arrColumns[] = Product::getTable() . ".dateAdded<" . Isotope::getConfig()->getNewProductLimit();
     }
     if ($this->iso_list_where != '') {
         $arrColumns[] = $this->iso_list_where;
     }
     if ($queryBuilder->hasSqlCondition()) {
         $arrColumns[] = $queryBuilder->getSqlWhere();
     }
     $arrSorting = Isotope::getRequestCache()->getSortingsForModules($this->iso_filterModules);
     if (empty($arrSorting) && $this->iso_listingSortField != '') {
         $direction = $this->iso_listingSortDirection == 'DESC' ? Sort::descending() : Sort::ascending();
         $arrSorting[$this->iso_listingSortField] = $direction;
     }
     $objProducts = Product::findAvailableBy($arrColumns, $queryBuilder->getSqlValues(), array('order' => 'c.sorting', 'filters' => $queryBuilder->getFilters(), 'sorting' => $arrSorting));
     return null === $objProducts ? array() : $objProducts->getModels();
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:42,代码来源:ProductVariantList.php

示例14: __construct

 public function __construct()
 {
     //SINGLETON------------------------------------
     $this->msgs = messages::getInstance();
     $this->db = Database::getInstance();
     //---------------------------------------------
 }
开发者ID:hera04,项目名称:fonelo,代码行数:7,代码来源:registerCtrl.class.php

示例15: XoopsTree

 function XoopsTree($table_name, $id_name, $pid_name)
 {
     $this->db =& Database::getInstance();
     $this->table = $table_name;
     $this->id = $id_name;
     $this->pid = $pid_name;
 }
开发者ID:BackupTheBerlios,项目名称:xoops4-svn,代码行数:7,代码来源:xoopstree.php


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