本文整理汇总了PHP中db_connect::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP db_connect::connect方法的具体用法?PHP db_connect::connect怎么用?PHP db_connect::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db_connect
的用法示例。
在下文中一共展示了db_connect::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: dirname
function __construct()
{
require_once dirname(__FILE__) . '/db_connect.php';
// opening db connection
$db = new db_connect();
$this->conn = $db->connect();
}
示例3: getData
protected static function getData($query)
{
$out=array();
foreach (self::aaa($query) as $key => $value) {
$out[$key] = $value;
}
parent::connect()->close();
return $out;
}
示例4: __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);
}
示例5: setData
protected static function setData($query)
{
$out = array();
$result = parent::connect()->query($query);
if ($result->num_rows > 0) {
foreach ($result as $key => $value) {
$out[$key] = $value;
}
return $out;
}
return true;
}
示例6: __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);
}
}
示例7: 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;
}
示例8: 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;
}
示例9: actionUpdateUserData
function actionUpdateUserData($view)
{
$userArray = array();
$errorArray = array();
$session = $_SESSION['user'];
if (!empty($_POST['firstPassword']) && !empty($_POST['anderPassword']) && $_POST['firstPassword'] === $_POST['anderPassword']) {
$session->password = $_POST['firstPassword'];
} elseif (empty($_POST['firstPassword']) && $_POST['firstPassword'] != '' && empty($_POST['anderPassword']) && $_POST['firstPassword'] === $_POST['anderPassword']) {
$view->message = ["Пароли не совпадают или не все поля заполненны", "Внимание", 4];
$errorArray = $_POST;
$view->data = cabinet::getUserData($userArray, $errorArray);
echo $view->render('cabinet.php');
return;
}
foreach ($_POST as $key => $value) {
if ($key == 'firstPassword' || $key == 'anderPassword') {
if (empty($value)) {
continue;
}
}
if ($key == 'email') {
if (preg_match("~([a-zA-Z0-9!#\$%&\\'*+-/=?^_`{|}\\~])@([a-zA-Z0-9-]).([a-zA-Z0-9]{2,4})~", $value)) {
$userArray[$key] = htmlspecialchars($value);
continue;
} else {
$errorArray[$key] = htmlspecialchars($value);
continue;
}
}
if ($key == 'about') {
if (count($value) < 2000) {
$userArray[$key] = htmlspecialchars($value);
continue;
} else {
$errorArray[$key] = htmlspecialchars($value);
continue;
}
}
if ($key == 'phone') {
if (preg_match("/^[+0-9-]{5,30}\$/", $value)) {
$userArray[$key] = htmlspecialchars($value);
continue;
} else {
$errorArray[$key] = htmlspecialchars($value);
continue;
}
}
if (!preg_match('/^[A-Za-zАаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя0-9_]{2,30}$/', trim($value))) {
$errorArray[$key] = htmlspecialchars($value);
} else {
$userArray[$key] = htmlspecialchars($value);
}
//
}
if (!isset($errorArray)) {
$view->message = ["Неверные данные или заполненны не все обязательные поля", "Внимание", 4];
} elseif (isset($userArray) && empty($errorArray)) {
foreach ($session->dossier as $key => $value) {
if ($_SESSION['user']->dossier->{$key} && isset($userArray[$key])) {
$session->dossier->{$key} = $userArray[$key];
}
}
db_connect::connect();
$id = R::store($session);
if (!$id) {
$view->message = ["Ошибка записи. Проверьте данные", "Ошибка", 4];
}
$view->message = ["Ваши личные данные изменены:", "Данные изменены", 1];
$userArray = $errorArray = '';
} else {
$view->message = ["Ошибка записи. Проверьте данные", "Ошибка", 4];
}
$view->data = cabinet::getUserData($userArray, $errorArray);
echo $view->render('cabinet.php');
}
示例10: 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('Ошибка');
//}
示例11: getPageById
static function getPageById($id)
{
db_connect::connect();
$page = R::load('page', $id);
return $page;
}
示例12: 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;
}
示例13: array
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.echo
*/
include_once 'db_connect.php';
// opening db connection
$db = new db_connect();
$connetion = $db->connect();
$errors = array();
$data = array();
// put all the value from the input value, here we can see the value of key['myEmail']
$_POST = json_decode(file_get_contents('php://input'), true);
// checking for blank values.
if (empty($_POST['myPassword'])) {
$errors['myPassword'] = 'Password is required.';
}
if (empty($_POST['myEmail'])) {
$errors['myEmail'] = 'Email is required.';
}
if (empty($_POST['rolecode'])) {
$errors['rolecode'] = 'Role is required.';
}
if (!empty($errors)) {
// put the errors array in data array
$data['errors'] = $errors;
} else {
$data['message'] = 'Form data is going well';
// response back. and put the value out of json_decoded array
示例14: ping_db
//connect to database
function connect()
{
$this->connect = mysql_connect($this->server, $this->user, $this->pass);
if (!$this->connect) {
die("connection can not be established");
}
$db_select = mysql_select_db($this->database, $this->connect);
if (!$db_select) {
die("Database selection failed : " . mysql_error());
}
}
//ping to see whether the database has gone offline or not
private function ping_db()
{
}
//sanitize query to prevent sql-injection
function sanitize_query($query)
{
}
function close()
{
if (isset($this->connection)) {
mysql_close($this->connection);
}
}
}
$val = new db_connect();
$val->set_var($server, $user, $pass, $database);
$val->connect();
示例15:
function __construct()
{
include_once './connect.php';
$connect = new db_connect();
$this->link = $connect->connect();
}