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


PHP db::getConnection方法代码示例

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


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

示例1: open_con

 private function open_con()
 {
     if (isset($this->db)) {
         $this->db = db::getConnection();
     }
     //parent::getConnection();
 }
开发者ID:wftragni,项目名称:socialclick,代码行数:7,代码来源:user.php

示例2: getTotalProductsInCategory

 public static function getTotalProductsInCategory($categoryId)
 {
     $db = db::getConnection();
     $result = $db->query('SELECT count(id) AS count FROM product ' . 'WHERE status = "1" AND category_id = "' . $categoryId . '"');
     $result->setFetchMode(PDO::FETCH_ASSOC);
     $row = $result->fetch();
     return $row['count'];
 }
开发者ID:Constantinehub,项目名称:first_project,代码行数:8,代码来源:Product.php

示例3: db_con

 private function db_con()
 {
     if (!isset($this->db)) {
         $this->db = db::getConnection();
     }
     if ($this->db->connect_error) {
         //header('Location: '.SITE_URL);
     }
 }
开发者ID:wftragni,项目名称:socialclick,代码行数:9,代码来源:shorturl.php

示例4: open_con

 function open_con()
 {
     if (!isset($this->mysqli)) {
         @($this->mysqli = db::getConnection());
         if ($this->mysqli->connect_error) {
             die($this->mysqli->error);
         }
     }
 }
开发者ID:wftragni,项目名称:socialclick,代码行数:9,代码来源:link.php

示例5: __construct

 function __construct($scode = NULL)
 {
     require_once 'useragent/UASparser.php';
     $this->mysqli = db::getConnection();
     if ($this->mysqli->connect_error) {
         die("Database error ,cant connect");
     }
     $this->shortcode = $scode;
     $this->uaparse = new UAS\Parser(__DIR__ . '/useragent/uascache/', null, false, true);
     $this->cbua = $this->ClickByUserAgent();
 }
开发者ID:wftragni,项目名称:socialclick,代码行数:11,代码来源:StatsUrl.php

示例6: getCategoriesList

 public static function getCategoriesList()
 {
     $db = db::getConnection();
     $categoryList = array();
     $result = $db->query('SELECT id, name FROM category ORDER BY sort_order ASC');
     $i = 0;
     while ($row = $result->fetch()) {
         $categoryList[$i]['id'] = $row['id'];
         $categoryList[$i]['name'] = $row['name'];
         $i++;
     }
     return $categoryList;
 }
开发者ID:Constantinehub,项目名称:first_project,代码行数:13,代码来源:Category.php

示例7: getNewsList

 public static function getNewsList()
 {
     try {
         $db = db::getConnection();
         //Вызов статического метода для подключения к БД
     } catch (PDOException $e) {
         echo 'Не получилось подключиться к БД  ';
         echo $e->getMessage();
         die;
     }
     $newsList = array();
     //массив результатов
     //С помощью подключения к БД выполныется запрос к БД на вывод данных из таблици news, с сортировкой по дате, и на лимит в 10 строк
     $result = $db->query('SELECT id, title, date, short_content FROM news ORDER BY date DESC LIMIT 10');
     $i = 0;
     while ($row = $result->fetch()) {
         $newsList[$i]['id'] = $row['id'];
         $newsList[$i]['title'] = $row['title'];
         $newsList[$i]['date'] = $row['date'];
         $newsList[$i]['short_content'] = $row['short_content'];
         $i++;
     }
     return $newsList;
 }
开发者ID:Constantinehub,项目名称:example-mvc,代码行数:24,代码来源:News.php

示例8: db

<?php

/**
 * Created by PhpStorm.
 * User: Dahmani Alae
 * Date: 11/13/2015
 * Time: 2:12 PM
 */
require '../vendor/autoload.php';
require 'Config.php';
use Symfony\Component\HttpFoundation\Request;
$request = Request::createFromGlobals();
$db = new db();
$conn = $db->getConnection();
$data = json_decode($request->getContent());
$nom = $data->nom_secteur;
$stmt = $conn->prepare('insert into secteur(nom_secteur) values(:nom)');
$stmt->bindParam(':nom', $nom);
$stmt->execute();
$id = $conn->lastInsertId();
/**
 * add on sous secteur table
 */
$stt = $conn->prepare('insert into sous_secteur(nom_sous_secteur,id_secteur) values(:noms,:id)');
$var = array();
$var = $data->list_sous_secteur;
$stt->bindParam(':id', $id);
foreach ($var as $key) {
    $stt->bindParam(':noms', $key);
    $stt->execute();
}
开发者ID:DhaAlae,项目名称:AngularJs-php-json-Restfull-api-,代码行数:31,代码来源:addsecteur.php

示例9: array

<?php

# loader Nix libraries
require_once '../../src/Nix/loader.php';
use Nix\Debugging\Debugger, Nix\Database\Db;
Debugger::init(true);
Debugger::setLogPath(__DIR__ . '/../temp/');
Db::connect(array('database' => 'nix_examples'));
echo '<h2>escaping</h2>';
$a = array('test%r' => 'Now()', 'tests%s' => 'SuperTest\'', 'tsadst' => true);
dump(db::getConnection()->escapeArray($a));
echo '<h2>fetch field</h2>';
dump(Db::fetchField("select [name] from [albums] order by RAND() limit 1"));
echo '<h2>fetch all</h2>';
dump(Db::fetchAll("select * from [albums] order by [name] limit 3"));
echo '<h2>fetch pairs</h2>';
dump(Db::fetchPairs("select [id], [name] from [albums] order by RAND() limit 10"));
echo '<h2>fetch pairs</h2>';
dump(Db::fetchPairs("select [name] from [albums] order by RAND() limit 10"));
开发者ID:literat,项目名称:nix-examples,代码行数:19,代码来源:db.php

示例10: getUserById

 /**
  *Returns user by id
  *@param integer $id
  **/
 public static function getUserById($id)
 {
     if ($id) {
         $db = db::getConnection();
         $sql = 'SELECT * FROM user WHERE id = :id';
         $result = $db->prepare($sql);
         $result->bindParam(':id', $id, PDO::PARAM_INT);
         //Указываем что хотим получить данные в виде массива
         $result->setFetchMode(PDO::FETCH_ASSOC);
         $result->execute();
         return $result->fetch();
     }
 }
开发者ID:Constantinehub,项目名称:first_project,代码行数:17,代码来源:User.php

示例11: __construct

 public function __construct()
 {
     parent::__construct();
     $this->pdo = parent::getConnection();
 }
开发者ID:astonecipher,项目名称:Automotive-CMS,代码行数:5,代码来源:Page.php


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