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


PHP Db::getConnection方法代码示例

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


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

示例1: test_getConnection

 public function test_getConnection()
 {
     /** === Setup Mocks === */
     $this->mResource->shouldReceive('getConnection')->andReturn($this->mConn);
     /** === Call and asserts  === */
     $res = $this->obj->getConnection();
     $this->assertInstanceOf(\Magento\Framework\DB\Adapter\AdapterInterface::class, $res);
 }
开发者ID:praxigento,项目名称:mobi_mod_mage2_core,代码行数:8,代码来源:Db_Test.php

示例2: getNewsList

 public static function getNewsList()
 {
     // Запрос к БД
     $conn = Db::getConnection();
     $newsList = array();
     $sql = 'SELECT id, title, date, short_content ' . 'FROM news ' . 'ORDER BY date DESC ';
     $stmt = $conn->prepare($sql);
     //dayardayt
     /* execute prepared statement */
     $stmt->execute();
     //zapros
     $stmt->store_result();
     // zapros
     if ($stmt->num_rows > 0) {
         $stmt->bind_result($id, $title, $date, $sh_content);
         // kelgen maanini yigarat
         // output data of each row
         $i = 0;
         while ($row = $stmt->fetch()) {
             $newsList[$i]['id'] = $id;
             $newsList[$i]['title'] = $title;
             $newsList[$i]['date'] = $date;
             $newsList[$i]['sh_content'] = $sh_content;
             $i++;
         }
     }
     return $newsList;
 }
开发者ID:nurik1kg,项目名称:mvc_php,代码行数:28,代码来源:News.php

示例3: getNewsList

 public static function getNewsList()
 {
     //запрос к БД
     $db = Db::getConnection();
     //вызываем метод с параметрами подкдючения к базе данных
     $newsList = array();
     //Создем пустой масив для сохранения результатов
     $result = $db->query('SELECT id,title,date,short_content FROM news LIMIT 4');
     //Нужний запрос к БД
     if (!$result) {
         die("Execute query error");
     }
     $i = 0;
     while ($row = $result->fetch(true)) {
         // $row -символизирует строку из базы даных
         //В цикле мы записываем необходимые даные в масив результатов
         $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:StanislavRybonka,项目名称:Own_Work_Directory,代码行数:25,代码来源:News.php

示例4: check

 public function check()
 {
     $username = $_POST['username'];
     $password = $_POST['password'];
     $conn = Db::getConnection();
     $sql = "SELECT username, password, admin\n\t\t\t\tFROM users\n\t\t\t\tWHERE username = '{$username}'";
     $q = $conn->prepare($sql);
     $q->execute();
     $users = $q->fetch(\PDO::FETCH_ASSOC);
     //var_dump($users);die('  proba');
     $logger = new Logger();
     $error = $logger->checkCredentials($password, $users);
     //$isAdmin = $logger->checkAdmin($password,$users);
     //var_dump($error);die('   ajde vise!!!');
     if ($error) {
         //echo '<pre>'; var_dump($error);die(); echo '</pre>';
         $html = new Html($this->controllerName);
         $html->error = $error;
         //echo '<pre>'; var_dump($html->error);die(); echo '</pre>';
         $html->render('index');
     } else {
         $user = new User($users['username'], $users['admin']);
         $user->login();
         //var_dump($user);die('   jebem li ga');
         header('Location: /');
     }
 }
开发者ID:Mikili975,项目名称:news_obj,代码行数:27,代码来源:LoginController.php

示例5: Reg

 public static function Reg($reg_name, $reg_surname, $reg_phone, $reg_email, $reg_location, $reg_password_hash, $reg_avatar)
 {
     $db = Db::getConnection();
     $query = $db->prepare("INSERT INTO registration (reg_id, reg_name, reg_surname, reg_date, reg_phone, reg_email, reg_location, reg_password_hash, vk_account, reg_avatar) \n\t\t\t\t\t\t\t\tVALUES (NULL, :reg_name, :reg_surname, CURRENT_TIMESTAMP, :reg_phone, :reg_email, :reg_location, :reg_password_hash, 0, :reg_avatar);");
     $query->execute(array('reg_name' => "{$reg_name}", 'reg_surname' => "{$reg_surname}", 'reg_phone' => "{$reg_phone}", 'reg_email' => "{$reg_email}", 'reg_location' => "{$reg_location}", 'reg_password_hash' => "{$reg_password_hash}", 'reg_avatar' => "{$reg_avatar}"));
     return $query;
 }
开发者ID:artempronevskiy,项目名称:shabashka_back-end_front_end,代码行数:7,代码来源:RegModel.php

示例6: create

 public function create()
 {
     $firstname = $_POST['firstname'];
     $lastname = $_POST['lastname'];
     $email = $_POST['email'];
     $username = $_POST['username'];
     $password = password_hash($_POST['password'], PASSWORD_BCRYPT);
     $conn = Db::getConnection();
     $sql = "SELECT *\n\t\t\t\tFROM users";
     $q = $conn->prepare($sql);
     $q->execute();
     $users = $q->fetchAll(\PDO::FETCH_ASSOC);
     $validator = new Validator();
     $error = $validator->validateRegisterForm($_POST, $users);
     //echo '<pre>'; var_dump($error); echo '</pre>';die();
     if ($error) {
         //echo '<pre>'; var_dump($error);die(); echo '</pre>';
         $html = new Html($this->controllerName);
         $html->error = $error;
         //echo '<pre>'; var_dump($html->error);die(); echo '</pre>';
         //;kweojn'dlfv'dlfkv
         $html->render('index');
     } else {
         $newUserSql = "INSERT INTO users\n\t\t\t(`firstname`, `lastname`, `email`, `username`, `password`, `admin`)\n\t\t\tVALUES\n\t\t\t('{$firstname}', '{$lastname}', '{$email}', '{$username}', '{$password}', '0')";
         $q = $conn->prepare($newUserSql);
         $q->execute();
         header('Location: /login/index');
     }
 }
开发者ID:Mikili975,项目名称:news_obj,代码行数:29,代码来源:RegisterController.php

示例7: 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:SamvelGitHub,项目名称:mytest,代码行数:8,代码来源:Product.php

示例8: GetInfo

 public static function GetInfo($reg_id)
 {
     $db = Db::getConnection();
     $query = $db->prepare("SELECT * FROM registration WHERE reg_id = :reg_id;");
     $query->execute(array('reg_id' => "{$reg_id}"));
     $result = $query->fetch();
     return $result;
 }
开发者ID:artempronevskiy,项目名称:shabashka_back-end_front_end,代码行数:8,代码来源:AuthModel.php

示例9: addUser

 public static function addUser($login, $password)
 {
     $db = Db::getConnection();
     $sql = 'INSERT INTO users (login, password) VALUES (:login, :password)';
     $result = $db->prepare($sql);
     $result->bindParam(':login', $login, PDO::PARAM_INT);
     $result->bindParam(':password', $password, PDO::PARAM_INT);
     $result->execute();
     return $result->execute();
 }
开发者ID:cfycfysx,项目名称:testSite,代码行数:10,代码来源:User.php

示例10: table

 static function table($with_db_name = true)
 {
     $conn = Db::getConnection('streams');
     $prefix = empty($conn['prefix']) ? '' : $conn['prefix'];
     $table_name = $prefix . 'notification';
     if (!$with_db_name) {
         return $table_name;
     }
     $db = Db::connect('streams');
     return $db->dbName() . '.' . $table_name;
 }
开发者ID:EGreg,项目名称:PHP-On-Pie,代码行数:11,代码来源:Notification.php

示例11: checkEmailExists

 public static function checkEmailExists($email)
 {
     $db = Db::getConnection();
     $sql = 'SELECT COUNT(*) FROM user WHERE email = :email';
     $result = $db->prepare($sql);
     $result->bindParam(':email', $email, PDO::PARAM_STR);
     $result->execute();
     if ($result->fetchColumn()) {
         return true;
     }
     return false;
 }
开发者ID:SamvelGitHub,项目名称:mytest,代码行数:12,代码来源:User.php

示例12: amIAdmin

 public static function amIAdmin($get_reg_id)
 {
     $db = Db::getConnection();
     $query = $db->prepare("SELECT is_admin FROM registration WHERE reg_id = :reg_id;");
     $query->execute(array('reg_id' => "{$get_reg_id}"));
     $result = $query->fetch();
     if ($result['is_admin'] == 1) {
         return True;
     } else {
         return False;
     }
 }
开发者ID:artempronevskiy,项目名称:shabashka_back-end_front_end,代码行数:12,代码来源:AdminModel.php

示例13: 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:SamvelGitHub,项目名称:mytest,代码行数:13,代码来源:Category.php

示例14: getList

 /**
  * Return array with list of works
  * @return array
  */
 public static function getList()
 {
     $db = Db::getConnection();
     $list = array();
     $result = $db->query('SELECT title, link FROM base WHERE type="uslugi"');
     $i = 0;
     while ($row = $result->fetch()) {
         $list[$i]['title'] = $row['title'];
         $list[$i]['link'] = $row['link'];
         $i++;
     }
     return $list;
 }
开发者ID:seredenko,项目名称:mvc_sigmaplus,代码行数:17,代码来源:Uslugi.php

示例15: getCategoriesList

 /**
  * Returns an array of categories
  */
 public static function getCategoriesList()
 {
     $db = Db::getConnection();
     $categoryList = array();
     $result = $db->prepare('SELECT id, name FROM category ORDER BY sort_order ASC');
     $result->execute();
     $row = $result->fetchAll(PDO::FETCH_ASSOC);
     for ($i = 0; $i < count($row); $i++) {
         $categoryList[$i]['id'] = $row[$i]['id'];
         $categoryList[$i]['name'] = $row[$i]['name'];
     }
     return $categoryList;
 }
开发者ID:scorpion1986,项目名称:site,代码行数:16,代码来源:Category.php


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