本文整理汇总了PHP中connect类的典型用法代码示例。如果您正苦于以下问题:PHP connect类的具体用法?PHP connect怎么用?PHP connect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了connect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getToken
function getToken()
{
require_once 'comm.php';
$currnet = time();
$Token_result = new connect();
$sql = "SELECT * FROM options where type='token'";
$result = $Token_result->query($sql);
$arr = mysql_fetch_array($result);
$time_token = $arr['value'];
if ($currnet >= $time_token) {
$appid = "wxa2986e7d8863b2ab";
$secret = "08d000097799e646d11b57e0acd71a9f";
$access_token = file_get_contents("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}");
$access_token = json_decode($access_token);
$access_token = $access_token->{'access_token'};
//修改新的token信息
$time = $currnet + 7200;
$sql = "UPDATE options SET title='" . $access_token . "',value='" . $time . "' where type='token'";
$Token_result->query($sql);
} else {
$access_token = $arr['title'];
//$access_token ="48QToD2xXqQSwSNF8uqn6iF3o3P4yDEqvrrxaDDO0nxqcZFgg95IwA_xAafzwhsVxcM4Hh0tQTtwIcTqFxEa_B1IUpXE67cVUmpBnq_09rE";
}
return $access_token;
}
示例2: state
function state($ch)
{
$con = new connect();
$rs = $con->Query(" select * from admin,client where email='{$ch}' and admin.id=client.id_client ");
$data = $rs->fetch_array();
return $data["state"];
}
示例3: edit_privilege_one
function edit_privilege_one($table, $id)
{
if ($_SESSION['user_type'] == 1) {
return "1";
}
$ob1 = new connect();
if ($table == "users") {
$sql = mysqli_query($ob1->dbcon(), "SELECT * FROM `{$table}` WHERE `user_id` = '{$id}'");
} else {
$sql = mysqli_query($ob1->dbcon(), "SELECT * FROM `{$table}` WHERE `id` = '{$id}'");
}
if ($row = mysqli_fetch_array($sql)) {
if ($table != "accounts") {
//check if this assigned to this user
if ($row['assignedto'] == $_SESSION['user_id']) {
return "1";
}
}
if ($_SESSION['_' . $row['group']][$table] == 2 || $_SESSION['_' . $row['group']][$table] == 3 || $_SESSION['_' . $row['group']][$table] == 6 || $_SESSION['_' . $row['group']][$table] == 7) {
return "1";
} else {
return "0";
}
}
}
示例4: __construct
function __construct()
{
require_once "include/connect.php";
$db = new connect();
//instance of the class connect
$this->conn = $db->db_connect();
//connecting to the databse using $conn
}
示例5: inscrire
function inscrire($nom, $prenom, $email, $pwd, $state)
{
$con = new connect();
if ($con->Query(" insert into admin (email,password) values ('{$email}','{$pwd}') ")) {
$a = $con->Query("select * from admin where email='{$email}' ");
$data = $a->fetch_array();
$this->id_client = $data["id"];
$RIB = $this->generateID();
$con->Query(" insert into client (nom,prenom,id_client,state,RIB,solde) values ('{$nom}','{$prenom}','{$this->id_client}','{$state}','{$RIB}','0') ");
echo "registered with success";
} else {
echo "fail to insert";
}
}
示例6: start
/**
* почти конструктор
* @param null|int|string $type
* @param null|string $host
* @param null|string $base
* @param null|string $user
* @param null|string $pwd
* @return connect|null
*/
public static function start($type = NULL, $host = NULL, $base = NULL, $user = NULL, $pwd = NULL)
{
if (self::$inst == null) {
self::$inst = new connect($type, $host, $base, $user, $pwd);
}
return self::$inst;
}
示例7: setConexion
private function setConexion()
{
$conf = connect::getInstance();
$this->servidor = $conf->getHostDB();
$this->base_datos = $conf->getDB();
$this->usuario = $conf->getUserDB();
$this->password = $conf->getPassDB();
}
示例8: __construct
/**
* builder constructor.
* @param string $tbuild
* @param string $lang
* @param int $server
* @param string $mwcedb
*/
public function __construct($tbuild, $lang, $server, $mwcedb = "mwce_settings")
{
$this->DB = connect::start();
$this->build = $tbuild;
$this->lang = $lang;
$this->server = $server;
$this->mwcedb = $mwcedb;
$this->checkBase();
}
示例9: connectToRealmDB
public static function connectToRealmDB($realmid)
{
self::selectDB('webdb');
if ($GLOBALS['realms'][$realmid]['mysql_host'] != $GLOBALS['connection']['host'] || $GLOBALS['realms'][$realmid]['mysql_user'] != $GLOBALS['connection']['user'] || $GLOBALS['realms'][$realmid]['mysql_pass'] != $GLOBALS['connection']['password']) {
mysql_connect($GLOBALS['realms'][$realmid]['mysql_host'], $GLOBALS['realms'][$realmid]['mysql_user'], $GLOBALS['realms'][$realmid]['mysql_pass']) or buildError("<b>Database Connection error:</b> A connection could not be established to Realm. Error: " . mysql_error(), NULL);
} else {
self::connectToDB();
}
mysql_select_db($GLOBALS['realms'][$realmid]['chardb']) or buildError("<b>Database Selection error:</b> The realm database could not be selected. Error: " . mysql_error(), NULL);
self::$connectedTo = 'chardb';
}
示例10: countrows1
function countrows1($tablename, $field, $value)
{
$ob1 = new connect();
$ids = join(',', $_SESSION['user_groups']);
$sql = mysqli_query($ob1->dbcon(), "SELECT COUNT(id) AS `count` FROM `{$tablename}` WHERE `deleted` = '0' AND `{$field}`='{$value}' AND `group` IN ({$ids})");
// this use for users
if ($_SESSION['user_type'] == '1') {
$sql = mysqli_query($ob1->dbcon(), "SELECT COUNT(id) AS `count` FROM `{$tablename}` WHERE `deleted` = '0' AND `{$field}`='{$value}' ");
// this use for admin
}
$row = mysqli_fetch_assoc($sql);
return $row['count'];
}
示例11: init
public static function init($type)
{
if ($GLOBALS['enablePlugins'] == true) {
if ($_SESSION['loaded_plugins'] != NULL) {
$bad = array('.', '..', 'index.html');
$loaded = array();
foreach ($_SESSION['loaded_plugins'] as $folderName) {
connect::selectDB('webdb');
$chk = mysql_query("SELECT COUNT(*) FROM disabled_plugins WHERE foldername='" . mysql_real_escape_string($folderName) . "'");
if (mysql_result($chk, 0) == 0 && file_exists('plugins/' . $folderName . '/' . $type . '/')) {
$folder = scandir('plugins/' . $folderName . '/' . $type . '/');
foreach ($folder as $fileName) {
if (!in_array($fileName, $bad)) {
$loaded[] = 'plugins/' . $folderName . '/' . $type . '/' . $fileName;
}
}
$_SESSION['loaded_plugins_' . $type] = $loaded;
}
}
}
}
}
示例12: user_can_delete_groups
function user_can_delete_groups($table)
{
$loguser = $_SESSION['user_id'];
$ob1 = new connect();
// $sql=" SELECT * FROM `user_group` WHERE `user_id` = '$loguser' AND ($table > '2' OR $table > '3' OR $table > '6' OR $table > '7' )";
if ($_SESSION['user_type'] == '1') {
$sql = "SELECT * FROM groups WHERE deleted = '0' ";
} else {
$sql = "SELECT user_group.*,groups.group_name FROM user_group\n LEFT OUTER JOIN groups ON user_group.group_id = groups.group_id\n WHERE user_group.user_id = '{$loguser}' AND (user_group.{$table} ='1' OR user_group.{$table} = '3' OR user_group.{$table} = '5' OR user_group.{$table} = '7' )";
}
// echo $sql;
return mysqli_query($ob1->dbcon(), $sql);
}
示例13: connect
.link{
background-color:#DAA520;
color:#484848;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body bgcolor="#A9A9A9">
<center>
<h1>COURSE RERGISTRATION</h1>
<form method="post" action="#">
<?php
if (isset($_POST['submit'])) {
require_once "reg.php";
$x = new connect();
if ($x->course()) {
header('Location: home.php');
} else {
echo "error";
}
}
?>
<pre>
GRADUATION: <input type="radio" name="graduation" value="UG" />UG <input type="radio" name="graduation" value="PG" />PG
Degree: <select name="degree">
<option value="select option" selected> Select category</option>
<option value="B.Tech">B.Tech</option>
<option value="M.Tech">M.Tech</option>
示例14: DeleteData
public function DeleteData($users, $passwords, $dbName, $table, $id)
{
$con_user = $users;
$con_pass = $passwords;
$con_name = $dbName;
$connection_object = new connect();
if (!empty($con_user) && !empty($con_pass)) {
$dbcon = $connection_object->connection('localhost', $con_user, $con_pass, $con_name);
} else {
$dbcon = $connection_object->connection('localhost', 'root', '', $con_name);
}
$sql = "delete from {$table} where `id`={$id}";
//$query=mysql_query($sql);
$deleteStatement = $dbcon->prepare($sql);
$deleteStatement->execute(array(':id' => $id));
}
示例15: connection
var $pass;
var $db;
public $connect;
public function connection($hostname, $username, $passwoard, $database)
{
$this->host = $hostname;
$this->user = $username;
$this->pass = $passwoard;
$this->db = $database;
$connect = new PDO("mysql:host={$this->host};dbname={$this->db}", $this->user, $this->pass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$connect->setAttribute(PDO::ATTR_PERSISTENT, true);
return $connect;
}
}
$connection_object = new connect();
include 'database_config.php';
$db_user = $database_user;
$db_pass = $databse_pass;
$dbcon = $connection_object->connection('localhost', $db_user, $db_pass, 'student_kpi');
//start from here
$batch = $_POST['b_id'];
$group = $_POST['g_id'];
$student_id = $_POST['s_id'];
$std_names = $_POST['name'];
$att = $_POST['attendance'];
$en_date = $_POST['entry_date'];
$preparedStatement = $dbcon->prepare('INSERT INTO student_attendance (s_id, name, b_id, g_id, attendance, entry_date)
VALUES (:sid, :sname, :bid, :gid, :atten, :ent_date)');
$arrlength = count($student_id);
for ($x = 0; $x < $arrlength; $x++) {