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


PHP Database::getDatabase方法代码示例

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


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

示例1: getTranslation

 static function getTranslation($key, $defaultContent = '')
 {
     /* are we in language debug mode */
     if (SITE_CONFIG_LANGUAGE_SHOW_KEY == "key") {
         return strlen($defaultContent) ? $defaultContent : $key;
     }
     /* return the language translation if we can find it */
     $constantName = "LANGUAGE_" . strtoupper($key);
     if (!defined($constantName)) {
         if (strlen($defaultContent)) {
             $db = Database::getDatabase();
             $languageId = $db->getValue("SELECT id FROM language WHERE languageName = " . $db->quote(SITE_CONFIG_SITE_LANGUAGE));
             if (!(int) $languageId) {
                 return false;
             }
             // insert default key value
             $dbInsert = new DBObject("language_key", array("languageKey", "defaultContent", "isAdminArea"));
             $dbInsert->languageKey = $key;
             $dbInsert->defaultContent = $defaultContent;
             $dbInsert->isAdminArea = 0;
             $dbInsert->insert();
             // set constant
             define("LANGUAGE_" . strtoupper($key), $defaultContent);
             return $defaultContent;
         }
         return "<font style='color:red;'>SITE ERROR: MISSING TRANSLATION *** <strong>" . $key . "</strong> ***</font>";
     }
     return constant($constantName);
 }
开发者ID:farzam65,项目名称:YetiShare-File-Hosting-Script-Free,代码行数:29,代码来源:class.translate.php

示例2: __construct

 public function __construct()
 {
     $this->connection = Database::getDatabase();
     $this->userController = new UsersController();
     $this->categoryController = new CategoryController();
     $this->parentCategoryController = new ParentCategoryController();
 }
开发者ID:junilm,项目名称:MyMap_AdminPanel,代码行数:7,代码来源:PoiController.php

示例3: POST

 public function POST()
 {
     //        throw new RESTMethodNotImplementedException ('Pesquisa', 'POST');
     $sk = new SecureKeyAuth();
     $sk->checkAuth();
     $params = $this->getPostParams();
     $fields = implode(',', array_keys($params));
     $keyparams = implode(',', array_map(function ($value) {
         return ':' . $value;
     }, array_keys($params)));
     $db = Database::getDatabase();
     try {
         $st = $db->prepare("INSERT INTO pesquisa ({$fields}) VALUES ({$keyparams})");
         foreach ($params as $field => $value) {
             $tipo = is_int($value) ? PDO::PARAM_INT : PDO::PARAM_STR;
             $st->bindValue(':' . $field, $value, $tipo);
         }
         if ($st->execute()) {
             $this->setResult(array('status' => 'OK'));
         } else {
             //$this->setResult($db->errorInfo());
             $this->setResult(array('status' => 'ERROR', 'fields' => $fields, 'keyparams' => $keyparams, 'sqlerrorcode' => $db->errorCode()));
         }
     } catch (PDOException $ex) {
         throw new RESTObjectException('Database insert fail');
     }
 }
开发者ID:bigeyessolution,项目名称:service.Carnaval.de.Juazeiro.2016,代码行数:27,代码来源:Pesquisa.php

示例4: track

 public static function track($file, $rs = '')
 {
     $db = Database::getDatabase();
     if (SITE_CONFIG_STATS_ONLY_COUNT_UNIQUE == 'yes') {
         // check whether the user has already visited today
         $sql = "SELECT * FROM stats WHERE ip = " . $db->quote(self::getIP()) . " AND page_title = " . $file->id . " AND DATE(dt) = " . $db->quote(date('Y-m-d'));
         $row = $db->getRows($sql);
         if (COUNT($row)) {
             return false;
         }
     }
     $file->updateVisitors();
     $dt = date("Y-m-d H:i:s");
     $referer = getenv('HTTP_REFERER');
     $referer_is_local = self::refererIsLocal($referer);
     $url = full_url();
     $img_search = '';
     $ip = self::getIP();
     $info = self::browserInfo();
     $browser_family = $info['browser'];
     $browser_version = $info['version'];
     $os = $info['platform'];
     $os_version = '';
     $user_agent = $info['useragent'];
     $country = self::getCountry($ip);
     $base_url = self::getBaseUrl($referer);
     $sql = "INSERT INTO stats (dt, referer, referer_is_local, url, page_title, country, img_search, browser_family, browser_version, os, os_version, ip, user_agent, base_url)\n                    VALUES (:dt, :referer, :referer_is_local, :url, :page_title, :country, :img_search, :browser_family, :browser_version, :os, :os_version, :ip, :user_agent, :base_url)";
     $vals = array('dt' => $dt, 'referer_is_local' => $referer_is_local, 'referer' => $referer, 'url' => $url, 'page_title' => $file->id, 'country' => $country, 'img_search' => $img_search, 'ip' => $ip, 'browser_family' => $browser_family, 'browser_version' => $browser_version, 'os_version' => $os_version, 'os' => $os, 'user_agent' => $user_agent, 'base_url' => $base_url);
     $db->query($sql, $vals);
     return true;
 }
开发者ID:farzam65,项目名称:YetiShare-File-Hosting-Script-Free,代码行数:31,代码来源:class.stats.php

示例5: __construct

 function __construct($id)
 {
     $db = Database::getDatabase();
     $this->data = $db->querySingle(sprintf("select * from exception_logging where id = %d", $id));
     if (!$this->data) {
         throw new NotFound();
     }
     $this->data['error_info'] = unserialize(base64_decode($this->data['error_info']));
     $pr = preg_quote(c()->getValue('report_format', 'app_root'), '#');
     if (!$this->data['error_info']['callstack']) {
         $this->data['error_info']['callstack'] = array();
     }
     $this->data['error_info']['callstack'] = array_merge(array(array('line' => $this->data['error_info']['line'], 'file' => $this->data['error_info']['file'], 'function' => 'throw', 'args' => array())), $this->data['error_info']['callstack']);
     foreach ($this->data['error_info']['callstack'] as &$csi) {
         if ($pr) {
             $csi['base_file'] = preg_replace("#^{$pr}/?#", '', $csi['file']);
             $csi['file'] = preg_replace("#^{$pr}/?#", '<R>/', $csi['file']);
             $csi['scm_link'] = $this->getWebSCMLink($csi['base_file'], $csi['line']);
         }
         if ($csi['class']) {
             $csi['call'] = sprintf('%s%s%s(%s)', $csi['class'], $csi['type'], $csi['function'], implode(', ', array_map(array($this, 'formatArgument'), $csi['args'])));
         } else {
             $csi['call'] = sprintf('%s(%s)', $csi['function'], implode(', ', array_map(array($this, 'formatArgument'), $csi['args'])));
         }
     }
     if ($fs = c()->getValue('report_format', 'interesting_custom_fields')) {
         $fs = explode(',', $fs);
         foreach ($fs as $f) {
             $this->data[$f] = $this->data['error_info'][$f];
         }
     }
 }
开发者ID:pilif,项目名称:phexrep,代码行数:32,代码来源:exception_report.php

示例6:

 /**
  * Constructor
  * Use $db->createResult( $parent, $name ) instead
  *
  * @param Database|Result|Row $parent
  * @param string $name
  */
 function __construct($parent, $name)
 {
     if ($parent instanceof Database) {
         // basic result
         $this->db = $parent;
         $this->table = $this->db->getAlias($name);
     } else {
         // Row or Result
         // result referenced to parent
         $this->parent_ = $parent;
         $this->db = $parent->getDatabase();
         // determine type of reference based on conventions and user hints
         $fullName = $name;
         $name = preg_replace('/List$/', '', $fullName);
         $this->table = $this->db->getAlias($name);
         $this->single = $name === $fullName;
         if ($this->single) {
             $this->key = $this->db->getPrimary($this->getTable());
             $this->parentKey = $this->db->getReference($parent->getTable(), $name);
         } else {
             $this->key = $this->db->getBackReference($parent->getTable(), $name);
             $this->parentKey = $this->db->getPrimary($parent->getTable());
         }
     }
 }
开发者ID:morris,项目名称:lessql,代码行数:32,代码来源:Result.php

示例7: __construct

 public function __construct($itemClass, $countSql, $pageSql, $page, $per_page)
 {
     $this->itemClass = $itemClass;
     $this->countSql = $countSql;
     $this->pageSql = $pageSql;
     $db = Database::getDatabase();
     $num_records = intval($db->getValue($countSql));
     parent::__construct($page, $per_page, $num_records);
 }
开发者ID:repsycle,项目名称:baseline,代码行数:9,代码来源:class.dbpager.php

示例8: GET

 public function GET()
 {
     $st = Database::getDatabase()->select('total_de_votos');
     $result = array();
     while ($row = $st->fetch(PDO::FETCH_ASSOC)) {
         $result[] = (object) $row;
     }
     $this->setResult(array('status' => 'OK', 'content' => (object) $result));
 }
开发者ID:bigeyessolution,项目名称:FestivalEdesio,代码行数:9,代码来源:TotalDeVotos.php

示例9: loadAllByAccount

 static function loadAllByAccount($accountId)
 {
     $db = Database::getDatabase(true);
     $rs = $db->getRows('SELECT * FROM file_folder WHERE userId = ' . $db->quote($accountId) . ' ORDER BY folderName');
     if (!is_array($rs)) {
         return false;
     }
     return $rs;
 }
开发者ID:farzam65,项目名称:YetiShare-File-Hosting-Script-Free,代码行数:9,代码来源:class.filefolder.php

示例10: getBannedType

 static function getBannedType()
 {
     $userIP = getUsersIPAddress();
     $db = Database::getDatabase(true);
     $row = $db->getRow('SELECT banType FROM banned_ips WHERE ipAddress = ' . $db->quote($userIP));
     if (!is_array($row)) {
         return false;
     }
     return $row['banType'];
 }
开发者ID:farzam65,项目名称:YetiShare-File-Hosting-Script-Free,代码行数:10,代码来源:class.bannedip.php

示例11: checkAuth

 public function checkAuth()
 {
     $params = $this->getPostParams();
     $db = Database::getDatabase();
     if ($db->select('device', "iddevice = {$params['iddevice']} and hash_key = '{$params['hash_key']}'")->fetch()) {
         return TRUE;
     } else {
         throw new RESTObjectException('This device has not permission');
     }
 }
开发者ID:bigeyessolution,项目名称:service.Carnaval.de.Juazeiro.2016,代码行数:10,代码来源:SecureDeviceHash.php

示例12: run

 public function run()
 {
     $db = Database::getDatabase();
     $rows = $db->getRows($this->query);
     $this->data = array();
     foreach ($rows as $row) {
         $x = $row[$this->xColumnName];
         $y = $row[$this->yColumnName];
         $this->data[$x] = $y;
     }
 }
开发者ID:yuantw,项目名称:Shine,代码行数:11,代码来源:stats.php

示例13: refreshContent

 public static function refreshContent($url, $expires_in = 300)
 {
     $str = self::getURL($url);
     $data = self::decodeStrData($str);
     if ($data === false) {
         return false;
     }
     $db = Database::getDatabase();
     $db->query("REPLACE INTO url_cache (url, dt_refreshed, dt_expires, data) VALUES (:url, :dt_refreshed, :dt_expires, :data)", array('url' => $url, 'dt_refreshed' => dater(), 'dt_expires' => dater(time() + $expires_in), 'data' => $str));
     return $str;
 }
开发者ID:repsycle,项目名称:baseline,代码行数:11,代码来源:class.urlcache.php

示例14: install

 public function install()
 {
     // Create tables
     $sql = file_get_contents(DOC_ROOT . '/apps/' . $this->data['app']['name'] . '/db.sql');
     // Do this to split up creations to one per query.
     $queries = explode('#', $sql);
     $db = Database::getDatabase();
     foreach ($queries as $query) {
         $db->query($query);
     }
     redirect(WEB_ROOT . $this->app_name . '/');
 }
开发者ID:robv,项目名称:konnect,代码行数:12,代码来源:class.controller.php

示例15: types

 public static function types()
 {
     $db = Database::getDatabase();
     $db->query("SHOW COLUMNS FROM users LIKE 'level'");
     $row = $db->getRow();
     $type = $row['Type'];
     preg_match('/enum\\((.*)\\)$/', $type, $matches);
     $vals = explode(',', $matches[1]);
     if (is_array($vals)) {
         return str_replace("'", '', $vals);
     } else {
         return false;
     }
 }
开发者ID:repsycle,项目名称:baseline,代码行数:14,代码来源:class.objects.php


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