本文整理汇总了PHP中db::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP db::getInstance方法的具体用法?PHP db::getInstance怎么用?PHP db::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db
的用法示例。
在下文中一共展示了db::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UpdateClient
public function UpdateClient($email, $mdp, $nom, $prenom)
{
$con = db::getInstance();
$req = "UPDATE exiastore.client SET Email = '" . $email . "' , Mdp = '" . $mdp . "' , Nom = '" . $nom . "' , Prenom = '" . $prenom . "' WHERE client.Email='" . $_SESSION['user']['user_info'] . "'";
$exec = $con->exec($req);
return 1;
}
示例2: __construct
public function __construct()
{
$this->table_pre = $this->db_config[$this->db_setting]['prefix'];
$this->table_name = $this->table_pre . $this->table_name;
$this->db = db::getInstance($this->db_config)->getDb($this->db_setting);
//获取数据库抽象层mysqli_db对象实例
}
示例3: __construct
public function __construct($par = null)
{
if (is_null($par)) {
$this->mysql = db::getInstance();
if (!empty($_POST['test']) && !empty($_POST['check'])) {
$test_id = (int) $_POST['test'];
$sum = 0;
foreach ($_POST['check'] as $ch) {
$r = $this->mysql->executeQuery("SELECT `id_set` FROM `set_to_test` WHERE `id_set`=:set_id AND `id_test`=:test_id", array(array(':test_id', $test_id, 'integer'), array(':set_id', (int) $ch, 'integer')));
$sum += $r['rows'];
}
if ($sum < 1) {
foreach ($_POST['check'] as $ch) {
$this->mysql->executeQuery("INSERT INTO `set_to_test` (`id_test`, `id_set`) VALUES (:test_id, :set_id)", array(array(':test_id', $test_id, 'integer'), array(':set_id', (int) $ch, 'integer')));
}
$this->data['alert'] = array('type' => 'success', 'mess' => array('addtotest'));
} else {
$this->data['alert'] = array('type' => 'warning', 'mess' => array('testanyet'));
}
}
parent::__construct('adm_menu_set');
$r = $this->mysql->executeQuery("SELECT `id_set`, `s_name` FROM `set`");
while ($row = $r['stmt']->fetch(PDO::FETCH_ASSOC)) {
$this->data['set'][] = $row;
}
$r = $this->mysql->executeQuery("SELECT `id_test`, `t_test_name` FROM `test`");
if ($r['rows'] >= 1) {
while ($row = $r['stmt']->fetch(PDO::FETCH_ASSOC)) {
$this->data['test'][] = $row;
}
}
}
}
示例4: process
public function process()
{
$user = user::getInstance();
$db = db::getInstance();
include './models/game.class.php';
include './models/grid.class.php';
// récupérer le gameid
$this->gameid = isset($_REQUEST['gameid']) ? intval($_REQUEST['gameid']) : false;
if ($this->gameid === false) {
trigger_error('Game not found', E_USER_ERROR);
}
// lecture de l'objet game
$game = new game();
$game->read($this->gameid);
// création d'une nouvelle grille
$gridtype = GRIDTYPE_ALLWORDS;
$grid = new grid();
$gridid = $grid->create($gridtype);
// ajout de la grille au game
$game->assign_grid($gridid);
$game->start_grid($gridid);
// enrichissement du retour json
$res = $grid->get();
$res->gameid = $this->gameid;
$res->gametype = GAMETYPE_PRACTICE_ALLWORDS;
header('Content-Type: application/json');
echo json_encode($res);
die;
}
示例5: search
public function search($search_query, $critere, $theme, $type)
{
$con = db::getInstance();
$req = 'SELECT * FROM Articles WHERE ' . $critere . ' LIKE \'%' . $search_query . '%\'' . $theme . $type;
$query = $con->query($req);
return $query->fetchAll();
}
示例6: display
private function display()
{
$db = db::getInstance();
$user = user::getInstance();
// refuser l'invitation
$deleteid = isset($_REQUEST['deleteid']) ? intval($_REQUEST['deleteid']) : false;
$delete = isset($_REQUEST['delete']) ? intval($_REQUEST['delete']) : false;
if ($delete == 1) {
$sql = 'DELETE FROM invitations
WHERE invitid = ' . $deleteid;
$db->query($sql);
}
// invitation reçues
$awaitings = array();
$sql = 'SELECT i.*, u.username
FROM invitations i, users u
WHERE u.userid = i.fromuserid
AND i.touserid = ' . intval($user->id);
$result = $db->query($sql);
while ($row = $result->fetch_assoc()) {
$awaitings[] = $row;
}
// invitations envoyées
$sents = array();
$sql = 'SELECT i.*, u.username
FROM invitations i, users u
WHERE u.userid = i.touserid
AND i.fromuserid = ' . intval($user->id);
$result = $db->query($sql);
while ($row = $result->fetch_assoc()) {
$sents[] = $row;
}
include './views/invitations.pendings.html';
return true;
}
示例7: ListeDeroulanteTypeCb
public function ListeDeroulanteTypeCb()
{
$con = db::getInstance();
$req = "SELECT typecb FROM typecb";
$query = $con->query($req);
return $query->fetchAll();
}
示例8: init
private function init()
{
// récupération de l'id de l'utilisateur et de sa langue étudiée
$this->user = user::getInstance();
$this->userlang = $this->user->langGame;
$this->createur = $this->user->id;
//récupération de la date au format jour/mois/année/heure
$this->et_c_est_le_temps_qui_court = date("d/m/Y H:i");
//récupération des points druides
$this->pointsDr = pointsDruid;
// récupération du formulaire de création de carte
$this->submit = isset($_POST['submit_form']);
if ($this->submit) {
$this->res['mot'] = isset($_POST['mot']) ? trim($_POST['mot']) : '';
$this->res['theme_carte'] = isset($_POST['theme_carte']) ? trim($_POST['theme_carte']) : '';
$this->res['nivcarte'] = isset($_POST['nivcarte']) ? trim($_POST['nivcarte']) : '';
$this->res['tabou1'] = isset($_POST['tabou1']) ? trim($_POST['tabou1']) : '';
$this->res['tabou2'] = isset($_POST['tabou2']) ? trim($_POST['tabou2']) : '';
$this->res['tabou3'] = isset($_POST['tabou3']) ? trim($_POST['tabou3']) : '';
$this->res['tabou4'] = isset($_POST['tabou4']) ? trim($_POST['tabou4']) : '';
$this->res['tabou5'] = isset($_POST['tabou5']) ? trim($_POST['tabou5']) : '';
$this->res['tabou6'] = isset($_POST['tabou6']) ? trim($_POST['tabou6']) : '';
}
$db = db::getInstance();
//A theme object would not have been bad… notimenow
$sql = 'SELECT DISTINCT `themeFR` FROM `themes` ORDER BY `themes`.`themeFR` ASC';
$db->query($sql);
$this->theme_carte = array();
while ($theme = $db->fetch_object()) {
array_push($this->theme_carte, $theme->themeFR);
}
return true;
}
示例9: check
private function check()
{
$db = db::getInstance();
if (!$this->submit) {
return false;
}
if (empty($this->username)) {
$this->errors[] = 'You must enter a user name';
}
if (empty($this->password)) {
$this->errors[] = 'You must enter a password';
}
if (!$this->errors) {
$sql = 'SELECT *
FROM users
WHERE username = ' . $db->escape((string) $this->username);
$result = $db->query($sql);
$row = $result->fetch_assoc();
$result->free();
if (!$row || md5($this->password) != $row['userpasswd']) {
$this->errors[] = 'The user name or the password are not a match.';
}
}
if (!$this->errors) {
$this->userid = intval($row['userid']);
}
}
示例10: updateBusinessInfor
/**
* @param $businessId
* @param $shopfrontPic
* @param $licencePic
* @throws Exception
*/
function updateBusinessInfor($businessId, $shopfrontPic, $licencePic)
{
$businessName = $_REQUEST['$businessName'];
$startTime = $_REQUEST['$startTime'];
$endTime = $_REQUEST['$endTime'];
$lon = $_REQUEST['$lon'];
$lat = $_REQUEST['$lat'];
$mobilePhone = $_REQUEST['$mobilePhone'];
$sortF = $_REQUEST['$sortF'];
$sortS = $_REQUEST['$sortS'];
$privileges = $_REQUEST['$privileges'];
$description = $_REQUEST['$description'];
$serviceindex = $_REQUEST['$serviceindex'];
$province = $_REQUEST['$province'];
$city = $_REQUEST['$city'];
$addresDetail = $_REQUEST['$addresDetail'];
$fixTelephone = $_REQUEST['$fixTelephone'];
// 字符必须添加'',数字不必添加
$sqlUpdate = "UPDATE\n `business`\n SET\n `name` = '{$businessName}',\n `sortF` = {$sortF},\n `sortS` = {$sortS},\n `privileges` = '{$privileges}',\n `picUrl` = '{$shopfrontPic}',\n `description` = '{$description}',\n `businessSTime` = {$startTime},\n `businessETime` = {$endTime},\n `licensePicUrl` = '{$licencePic}',\n `mobilePhone` = '{$mobilePhone}',\n `serviceindex` = {$serviceindex},\n `longitude` = {$lon},\n `latitude` = {$lat},\n `province` = {$province},\n `city` = {$city},\n `addresDetail` = '{$addresDetail}',\n `fixTelephone` = '{$fixTelephone}'\n WHERE\n `business`.`id` = {$businessId}";
$connect = db::getInstance()->connect();
$result = mysqli_query($connect, $sqlUpdate);
if ($result) {
echo '更新基本数据成功';
} else {
echo response::show(201, '更新基本数据失败');
}
}
示例11: read
public function read($gameid)
{
$db = db::getInstance();
$this->userids = array();
$this->gameid = 0;
$this->gametype = 0;
$this->gamelang = '';
$this->gamefinished = 0;
// lecture de l'entête
$sql = 'SELECT *
FROM games
WHERE gameid = ' . intval($gameid);
$result = $db->query($sql);
if (!($row = $result->fetch_assoc())) {
return false;
}
$this->gameid = intval($row['gameid']);
$this->gametype = intval($row['gametype']);
$this->gamelang = intval($row['gamelang']);
$this->gamefinished = intval($row['gamefinished']);
// lecture des utilisateurs
$sql = 'SELECT gu.*, u.username
FROM gamesusers gu, users u
WHERE gu.gameid = ' . intval($gameid) . '
AND u.userid = gu.userid';
$result = $db->query($sql);
while ($row = $result->fetch_assoc()) {
$this->userids[intval($row['userid'])] = $row['username'];
}
return true;
}
示例12: __construct
/**
* The constructor can either create the object from scratch, or retrieve it in the database.
* The one parameter constructor takes the card id and picks it up in db, whereas the regular one requires one value per attribute
*/
public function __construct($idOrLang, $extLangueOrView = NULL, $niveau = NULL, $categorie = NULL, $idDruide = NULL, $mot = NULL, $forb = NULL, $themes = NULL, $aview = NULL)
{
$this->db = db::getInstance();
if (!isset($mot)) {
//db fetch
if (is_int($idOrLang) || $idOrLang === (string) (int) $idOrLang) {
$this->get_from_id($idOrLang);
$this->set_view($extLangueOrView);
} else {
throw new Exception("{$idOrLang} (Card ID) is not an integer…");
}
} else {
//plein de paramètres
//testing data types would not be entirely superfluous…
$this->id = false;
$this->lang = $idOrLang;
$this->langPrecisions = $extLangueOrView;
$this->level = $niveau;
$this->cat = $categorie;
$this->author = $idDruide;
$this->guessWord = $mot;
/*getting unique values in a simple array (good to prevent duplicate key errors later on)*/
$this->themes = array_keys(array_flip($themes));
$this->forbiddenWords = array_keys(array_flip($forb));
$this->set_view($aview);
}
}
示例13: select_all
public function select_all()
{
$con = db::getInstance();
$req = "SELECT * FROM Articles";
$query = $con->query($req);
return $query->fetch();
}
示例14: InsertInscriptionAdresse
public function InsertInscriptionAdresse($email, $adresse, $ville, $cp)
{
$con = db::getInstance($email, $adresse, $ville, $cp);
$req = "INSERT INTO adresses (ID_Client, Adresse, Ville, CP) VALUES ((SELECT ID_Client FROM client WHERE Email = '" . $email . "'),'" . $adresse . "', '" . $ville . "', " . $cp . ")";
$exec = $con->exec($req);
return 1;
}
示例15: __construct
public function __construct($par = null)
{
$this->mysql = db::getInstance();
if (!empty($_POST['train']) && !empty($_POST['group']) && !empty($_POST['id'])) {
$this->mysql->executeQuery("UPDATE `user` SET `id_group`=:group WHERE `id_user`=:user_id", array(array(':group', (int) $_POST['group'], 'integer'), array(':user_id', (int) $_POST['id'], 'integer')));
$this->data['alert'] = array('type' => 'success', 'mess' => array('userupdate'));
}
if (is_null($par)) {
if (!empty($_POST['check']) && !empty($_POST['group'])) {
$gr_id = (int) $_POST['group'];
$sum = 0;
foreach ($_POST['check'] as $ch) {
$r = $this->mysql->executeQuery("SELECT `id_user` FROM `user_to_group` WHERE `id_user`=:user_id AND `id_student_group`=:group_id", array(array(':user_id', (int) $ch, 'integer'), array(':group_id', $gr_id, 'integer')));
$sum += $r['rows'];
}
if ($sum < 1) {
foreach ($_POST['check'] as $ch) {
$this->mysql->executeQuery("INSERT INTO `user_to_group` (`id_user`, `id_student_group`) VALUES (:user_id, :group_id)", array(array(':user_id', (int) $ch, 'integer'), array(':group_id', $gr_id, 'integer')));
}
$this->data['alert'] = array('type' => 'success', 'mess' => array('addtogroup'));
} else {
$this->data['alert'] = array('type' => 'warning', 'mess' => array('user_yet_gr'));
}
}
parent::__construct('adm_tabs_users');
$r = $this->mysql->executeQuery("SELECT `id_user`, `u_username`, `u_name`,`u_sname`,`id_group`, `u_reg_date` FROM `user`");
while ($row = $r['stmt']->fetch(PDO::FETCH_ASSOC)) {
$this->data['users'][$row['id_user']] = $row;
$this->data['users'][$row['id_user']]['u_training_name'] = '-';
$this->data['users'][$row['id_user']]['u_reg_date'] = date("d.m.y G:i", $this->data['users'][$row['id_user']]['u_reg_date']);
}
$r = $this->mysql->executeQuery("SELECT `id_user`, `sg_name` FROM `user_to_group` JOIN `student_group` USING (`id_student_group`) ");
while ($row = $r['stmt']->fetch(PDO::FETCH_ASSOC)) {
$this->data['users'][$row['id_user']]['u_training_name'] = $row['sg_name'];
}
$r = $this->mysql->executeQuery("SELECT `id_student_group`, `sg_name` FROM `student_group`");
if ($r['rows'] >= 1) {
while ($row = $r['stmt']->fetch(PDO::FETCH_ASSOC)) {
$this->data['group'][] = $row;
}
}
} else {
parent::__construct('adm_smen_uconf');
$id = (int) $par;
$r = $this->mysql->executeQuery("SELECT `u_username`, `u_name`,`u_sname` FROM `user` WHERE `id_user`=:user_id LIMIT 1", array(array(':user_id', $id, 'integer')));
if ($r['rows'] === 1) {
foreach ($r['stmt']->fetch(PDO::FETCH_ASSOC) as $k => $v) {
$this->data[$k] = $v;
}
$r = $this->mysql->executeQuery("SELECT `id_student_group`, `sg_name` FROM `student_group`");
while ($row = $r['stmt']->fetch(PDO::FETCH_ASSOC)) {
$this->data['stud_group'][] = $row;
}
$this->data['id'] = $id;
} else {
header('Location: ' . DIRURL . 'admin/users');
}
}
}