本文整理汇总了PHP中db_connect类的典型用法代码示例。如果您正苦于以下问题:PHP db_connect类的具体用法?PHP db_connect怎么用?PHP db_connect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了db_connect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
require_once dirname(__FILE__) . '/db_connect.php';
// opening db connection
$db = new db_connect();
$this->conn = $db->connect();
}
示例2: __construct
public function __construct()
{
include_once 'db_connect.php';
include_once 'functions.php';
try {
$connect_db = new db_connect();
$this->link = $connect_db->connect();
$this->functions = new db_functions();
} catch (Exception $ex) {
return mysqli_error($this->link);
}
}
示例3: getInstance
public static function getInstance()
{
if (!self::$_instance) {
self::$_instance = new db_connect();
}
return self::$_instance;
}
示例4: wisdomRecord
static function wisdomRecord($id = 0, $education = 0)
{
db_connect::connect();
if ($id != 0 && $education == 0) {
$information = R::load('information', $id);
$information->shortdescription = $_POST['shortdescription'];
$information->category_id = $_GET['category'];
$information->sharedUser[] = $_SESSION['user'];
} elseif ($id == 0 && $education == 0) {
$information = R::dispense('information');
$information->shortdescription = $_POST['shortdescription'];
$information->category_id = $_GET['category'];
$information->sharedUser[] = $_SESSION['user'];
} elseif ($id != 0 && $education != 0) {
// echo 1;
$information = R::load('education', $education);
$information->number = $_POST['number'];
$information->information_id = $id;
}
$information->name = $_POST['name'];
$information->description = $_POST['description'];
$id = R::store($information);
// print_r($id);
return $id;
}
示例5: connect
/**
* connexion a la BDD
*/
private static function connect () {
self::$db_connect = new mysqli(self::$DB_SRV, self::$DB_USER, self::$DB_MDP, self::$DB_NAME);
if (self::$db_connect->connect_error) {
die('Erreur de connexion (' . self::$db_connect->connect_errno . ') ' . self::$db_connect->connect_error);
}
self::$instance = TRUE;
}
示例6: __construct
public function __construct()
{
$this->_db = db_connect::getInstance();
$this->_mysqli = $this->_db->getConnection();
echo $this->PageHeader();
echo $this->LoadPageBody();
echo $this->LoadPageFooter();
$this->_functions = new functions();
}
示例7: __construct
function __construct($query, $array)
{
// $this->items = getDataBase::getData("SELECT *
// FROM `menu` , `menu_item`
// WHERE menu_item.menu_id =" . intval($id) . "
// AND menu.menu_id = menu_item.menu_id");
db_connect::connect();
$this->items = R::getAll($query, $array);
}
示例8: getWisdomByType
function getWisdomByType($array, $wisdomArray, $page = 1)
{
if (!(int) $array[0]) {
return false;
}
$out = '';
db_connect::connect();
if (empty($wisdomArray)) {
$out .= "<h2>Ничего не найдено</h2>";
return $out;
}
foreach ($wisdomArray as $key => $value) {
$out .= "<h2>" . $key . "</h2><table class='table table-striped'>\r\n <tr>\r\n <th>Название</th>\r\n <th>Автор</th>\r\n <th>Категория</th>\r\n <th>Субкатегория</th>\r\n </tr>";
foreach ($value as $smallKey => $subValue) {
$category = R::load('category', $subValue['subcategory_id']);
if ($array[3] && $array[2]) {
$step = 10;
$page3 = ($page - 1) * $step;
$data = $category->withCondition('information.category_id = ? LIMIT ?,?', [$array[3], $page3, $step])->ownInformationList;
self::$count_data += $category->withCondition('information.category_id = ? LIMIT ?,?', [$array[3], $page3, $step])->countOwn('information');
self::$path = "?ctrl=wisdom&action=WisdomType&type=" . $array[0] . "&subtype=" . $array[1] . "&category=" . $array[2] . "&subcategory=" . $array[3];
} else {
$step = 10;
$step1 = 2;
// echo $page;
$page2 = ($page - 1) * $step;
$page1 = ($page - 1) * $step1;
$data = $array[1] ? $category->with(' LIMIT ?,?', [$page2, $step])->ownInformationList : $category->with(' LIMIT ?,?', [$page1, $step1])->ownInformationList;
self::$count_data += $array[1] ? $category->with(' LIMIT ?,?', [$page2, $step])->countOwn('information') : $category->with(' LIMIT ?,?', [$page1, $step1])->countOwn('information');
// echo " ".self::$count_data." ";
self::$path = $array[1] ? "?ctrl=wisdom&action=WisdomType&type=" . $array[0] . "&subtype=" . $array[1] : "?ctrl=wisdom&action=WisdomType&type=" . $array[0];
}
foreach ($data as $item) {
if (!$item && $array[2]) {
$out .= "<tr><td colspan='4'><h4 class='text-center'><b>Ничего не найдено</b></h4></td></tr>";
continue;
}
$autor = self::getAuthorName($item->id);
$out .= "<tr>\r\n <td><a href='?ctrl=wisdom&action=GetWisdomById&id=" . $item->id . "'>" . $item->name . "</a></td>\r\n <td><a href='?ctrl=cabinet&action=UserInfo&id=" . $autor['id'] . "'>" . $autor['login'] . "</a> |\r\n <a href='?ctrl=cabinet&action=UserInfo&id=" . $autor['id'] . "'> " . $autor['surname'] . " " . $autor['name'] . " " . $autor['andername'] . " </a></td>\r\n <td>" . $smallKey . "</td>\r\n <td>" . $subValue['category_name'] . "</td>\r\n\r\n </tr>";
}
}
$out .= "</table>";
}
if ($array[3] && $array[2] && $_SESSION['user']->status == 'teacher' && $_SESSION['user']->block == 0) {
$out .= "<a role='button' href='?ctrl=teacher&action=WisdomData&type=" . $array[0] . "&subtype=" . $array[1] . "&category=" . $array[2] . "&subcategory=" . $array[3] . "&page=1' class='btn btn-info btn-block'>Добавить учебный материал</a>";
}
return $out;
}
示例9: categorMenu
static function categorMenu($array, $page = 1)
{
$open = '';
db_connect::connect();
$data = R::load('type', $array[0]);
$item = '';
if (!$array[1]) {
$item = $data->ownType;
} else {
$item = $data->withCondition('id = :id', ["id" => $array[1]])->ownType;
}
$out = "";
foreach ($item as $i) {
$i_count = 0;
if (!$array[2]) {
$j = $i->ownCategoryList;
} else {
$j = $i->withCondition('category.id = ? LIMIT 0,3', [$array[2]])->ownCategoryList;
}
foreach ($j as $v) {
$v_count = 0;
foreach ($v->ownCategory as $o) {
if (!$v_count && $o->name) {
$v_count = 1;
if ($v->id == $array[2]) {
$open = "open";
}
if (!$i_count) {
$i_count = 1;
$out .= "<h4>" . $i->name . "</h4>";
}
$out .= "<div class=\"dropdown {$open}\">\r\n <button class=\"btn btn-default btn-block dropdown-toggle\" type=\"button\" id=\"dropdownMenu1\" data-toggle=\"tooltip\"\r\n aria-haspopup=\"true\" aria-expanded=\"true\">\r\n <a href='?ctrl=wisdom&action=WisdomType&type=" . $data->id . "&subtype=" . $i->id . "&category=" . $v->id . "&page=1'>" . $v->name . "<span class=\"caret\"></span></a></button>\r\n <ul class=\"dropdown-menu\" aria-labelledby=\"dropdownMenu1\">";
}
if ($o->name) {
self::$information_count += $o->countOwn('information');
self::$wisdomArray[$i->name][$o->name]['type_id'] = $data->id;
self::$wisdomArray[$i->name][$o->name]['subtype_name'] = $i->name;
self::$wisdomArray[$i->name][$o->name]['category_name'] = $v->name;
self::$wisdomArray[$i->name][$o->name]['subcategory_id'] = $o->id;
$out .= "<li><a href='?ctrl=wisdom&action=WisdomType&type=" . $data->id . "&subtype=" . $i->id . "&category=" . $v->id . "&subcategory=" . $o->id . "&page=1'>" . $o->name . "</a></li>";
}
}
$out .= "</ul></div>";
}
}
return $out;
}
示例10: delete
public function delete(){
$query = "DELETE FROM TRIMESTRE WHERE idTrimestre = ".$this->getIdTrimestre();
if (db_connect::query($query))
return true;
return false;
}
示例11: delete
public function delete(){
$query = "DELETE FROM MATIERE_NIVEAU WHERE idMatiereNiveau = ".$this->getIdMatiereNiveau();
if (db_connect::query($query))
return true;
return false;
}
示例12: spl_autoload_register
<?php
/**
* Created by PhpStorm.
* User: инкогнито
* Date: 03.01.2016
* Time: 16:08
*/
require_once __DIR__ . '/autoload.php';
require_once __DIR__ . '/application/core/connect/db_connect.php';
//try {
if (!isset($_GET['ctrl'])) {
$ctrl = "defaultController";
$action = "actionDefault";
} else {
$controller = $ctrl = $_GET['ctrl'];
$ctrl .= 'Controller';
$action = 'action';
$action .= $_GET['action'];
}
spl_autoload_register('myAutoload');
db_connect::connect();
$view = new View();
$controller = new $ctrl();
$controller->{$action}($view);
// $view = new View();
// $view->abc = 123;
//} catch(Exception $e) {
// die('Ошибка');
//}
示例13: throw_the_bum_out
//copyright 2010,2014-2015 C.D.Price
$_TEMP_PERMIT = "_LEGAL_";
//a temp permission for the "are you logged in" gate (in prepend)
require_once "prepend.php";
require_once "common.php";
require_once "db_" . $_SESSION['_SITE_CONF']['DBMANAGER'] . ".php";
if (isset($_POST["btnSubmit"])) {
//logging out
throw_the_bum_out("Goodbye!", "Logout: by id=" . $_SESSION["person_id"]);
//let prepend take care of it (not really a bum)
}
$organization = "";
$person = "";
if (isset($_SESSION["person_id"])) {
//logged in
$db = new db_connect($_SESSION['_SITE_CONF']['DBEDITOR']);
$sql = "SELECT name FROM " . $db->prefix . "a00_organization WHERE organization_id=:org";
$stmt = $db->prepare($sql);
$stmt->bindValue(':org', $_SESSION["organization_id"], PDO::PARAM_INT);
$stmt->execute();
if (!($row = $stmt->fetchObject())) {
$organization = "--No Organization--";
} else {
$organization = COM_output_edit($row->name);
}
$stmt->closeCursor();
$sql = "SELECT firstname, lastname FROM " . $db->prefix . "c00_person WHERE person_id=:person";
$stmt = $db->prepare($sql);
$stmt->bindValue(':person', $_SESSION["person_id"], PDO::PARAM_INT);
$stmt->execute();
$row = $stmt->fetchObject();
示例14: __construct
function __construct()
{
require_once 'db_connect.php';
$db = db_connect::getInstance();
$this->conn = $db->getConnection();
}
示例15: userInfo
static function userInfo($id)
{
db_connect::connect();
$user = R::load('user', $id);
$status = $user->status == 'teacher' ? 'Преподаватель' : 'Студент';
$out = "<div class='col-sm-4 text-center'>\r\n <img style=\"max-width: 100%;max-height:100%;margin: 15px; \" src='images/user/" . $user->dossier->image . "'>\r\n </div>\r\n <div class='col-sm-8'>\r\n <h3>" . $user->login . " | " . $user->dossier->surname . " " . $user->dossier->name . " " . $user->dossier->andername . "</h3>";
$out .= "<ul class=\"list-group\">\r\n <li class=\"list-group-item\"><h4>Основная информация</h4></li>\r\n <li class=\"list-group-item\">Статус: " . $status . "</li>\r\n <li class=\"list-group-item\">Страна: " . $user->dossier->land . "</li>\r\n <li class=\"list-group-item\">Город: " . $user->dossier->sity . "</li>\r\n <li class=\"list-group-item\">Электронная почта: " . $user->dossier->email . "</li>\r\n <li class=\"list-group-item\">Количество учебных материалов: " . $user->withCondition('activ = 1 and education_id is null and lesson_id is null')->countShared('information') . " </li>\r\n </ul>\r\n </div>";
$about = $user->dossier->about ? $user->dossier->about : '<h3>Нет инфориации</h3>';
$out .= "<div class='col-sm-12'>\r\n <div class=\"panel panel-primary\">\r\n <div class=\"panel-heading\">О себе</div>\r\n <div class=\"panel-body\">" . $about . "</div>\r\n </div>\r\n </div>";
if ($user->status === 'teacher') {
$data = $user->withCondition('activ=1')->sharedInformationList;
// print_r($data);
$out .= "<div class='col-sm-12'><div class=\"list-group\"><ul style='padding-left:0; '>";
$out .= "<li class=\"list-group-item active\">\r\n <h4 class=\"list-group-item-heading \">Разработанные учебные материалы</h4>\r\n </li>";
foreach ($data as $item) {
$short_description = !empty($item->shortdescription) ? $item->shortdescription : 'Краткое описание отсутствует';
$out .= "<li class=\"list-group-item\">\r\n <h4 class=\"list-group-item-heading\"><a href='?ctrl=wisdom&action=GetWisdomById&id=" . $item->id . "'>" . $item->name . "</a></h4>\r\n <p class=\"list-group-item-text\">" . $short_description . "</p>\r\n </li>";
}
$out .= "</ul></div></div>";
}
return $out;
}