本文整理汇总了PHP中MysqliDb::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP MysqliDb::getInstance方法的具体用法?PHP MysqliDb::getInstance怎么用?PHP MysqliDb::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MysqliDb
的用法示例。
在下文中一共展示了MysqliDb::getInstance方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SetProperties
public function SetProperties($lang, $id, $name, $description)
{
if ($who = Registry::getInstance()->getUser()) {
if (isset($who['user_id']) && $who['user_id']) {
$this_prop = $this->ListProperties(array($lang), array(), array($id));
$db = MysqliDb::getInstance();
if ($this_prop) {
$data = array($this->_propertyType => $name, 'description' => $description, 'who_last_update' => $who['user_id']);
if ($db->where($this->_propertyType . '_id', $id)->where('language', $lang)->update($this->_propertyType . '_data', $data)) {
return $name;
} else {
return false;
}
} else {
$data = array($this->_propertyType . '_id' => $id, 'language' => $lang, $this->_propertyType => $name, 'description' => $description, 'who_last_update' => $who['user_id']);
if ($db->insert($this->_propertyType . '_data', $data)) {
return true;
} else {
return false;
}
}
} else {
return false;
}
} else {
return false;
}
}
示例2: showzx
function showzx()
{
$zid = req('zid');
$start = req('start', 0);
$perpage = req('perpage', 0);
if ($start < 0) {
$start = 0;
}
if (empty($perpage)) {
$perpage = 30;
}
if (empty($zid)) {
showjson('zid_not_exist');
}
$db = MysqliDb::getInstance();
$data = $db->rawQueryOne("SELECT z.*, u.username FROM zixun z LEFT JOIN users u ON z.uid=u.uid WHERE z.zid='{$zid}'");
if ($db->count > 0) {
$db->where("zid", $zid);
$stats = $db->getOne("comment", "count(*) as cnt");
$data['total'] = $stats['cnt'];
//if($start>=$data['total']) $start=0;
$comment = $db->rawQuery("SELECT c.*,s.username FROM comment c LEFT JOIN users s ON c.uid=s.uid WHERE c.zid='{$zid}' ORDER BY c.cid LIMIT {$start},{$perpage}");
$data['count'] = $db->count;
$data['comment'] = $comment;
showjson('do_success', 0, array("zixun" => $data));
}
showjson('show_error');
}
示例3: __construct
public function __construct()
{
/** @var array $db */
include_once 'config.php';
require_once 'PHP-MySQLi-Database-Class-master/MysqliDb.php';
new MysqliDb($db);
$this->db_instance = MysqliDb::getInstance();
$this->db_config = $db;
}
示例4: __construct
/**
* constructor
*
* @param string $type tipo de datamanager a ser incializado
*
* inicializa o objeto de log e de bd
* inicializa o vetor de dados nulo de acordo com o tipo
*/
function __construct($type)
{
$this->db = MysqliDb::getInstance();
$this->log = Log::getInstance();
//tipo de dado valido pra iniciar
if (array_key_exists($type, $this->_validFields)) {
$this->type = $type;
foreach ($this->_validFields[$this->type] as $key => $value) {
$this->setField($key, null);
}
}
}
示例5: buildOutput
/**
* Created by PhpStorm.
* User: André
* Date: 01/04/2015
* Time: 13:57
*/
function buildOutput($data, $debug = false)
{
$log = Log::getInstance();
$db = MysqliDb::getInstance();
$output = array();
if ($log->countErrors() > 0) {
$errors = $log->getErrors();
}
$output = $data;
if (isset($errors) && sizeof($errors) > 0) {
$output['_ERROR_'] = $errors;
}
if ($debug == 'true') {
$output['_DEBUG_'] = $log->getLogs();
}
echo json_encode($output, JSON_PRETTY_PRINT);
}
示例6: login
function login()
{
$password = req('password');
$username = req('username');
$db = MysqliDb::getInstance();
if ($password && $username) {
$db->where('username', $username);
if ($user = $db->getOne('users')) {
if ($user['password'] == $password) {
$auth = authcode("{$user['password']}\t{$user['uid']}", 'ENCODE');
showjson('do_success', 0, array("auth" => rawurlencode($auth)));
}
showjson('password_error');
}
}
showjson('login_error');
}
示例7: checkauth
function checkauth()
{
global $_SGLOBAL;
$auth = req('auth');
if ($auth) {
$db = MysqliDb::getInstance();
@(list($password, $uid) = explode("\t", authcode($auth, 'DECODE')));
$_SGLOBAL['uid'] = intval($uid);
if ($password && $_SGLOBAL['uid']) {
$db->where('uid', $_SGLOBAL['uid']);
if ($user = $db->getOne('users')) {
if ($user['password'] == $password) {
$_SGLOBAL['usertype'] = $user['usertype'];
$_SGLOBAL['username'] = $user['username'];
return;
}
}
}
}
showjson('to_login');
}
示例8: comment
function comment()
{
global $_SGLOBAL;
checkauth();
//验证登陆
$op = req('op');
$db = MysqliDb::getInstance();
if ($op == 'add') {
$setarr = array('uid' => $_SGLOBAL['uid']);
$setarr['message'] = req('message');
$setarr['zid'] = req('zid', 0);
if ($setarr['message'] && $setarr['zid']) {
$id = $db->insert('comment', $setarr);
//插入数据
if ($id) {
showjson('do_success', 0, array("cid" => $id));
}
showjson('submit_comment_error');
}
showjson('zid_or_message_can_not_empty');
} elseif ($op == 'del') {
$cid = req('cid', 0);
if (empty($cid)) {
showjson('non_normal_operation');
}
$db->where('cid', $cid);
if ($_SGLOBAL['usertype'] == 1) {
//是否管理员
} else {
$db->where('uid', $_SGLOBAL['uid']);
}
$result = $db->delete('comment');
//删除评论
if ($result) {
showjson('do_success', 0);
}
showjson('comment_not_exist');
}
}
示例9: __construct
/**
* @param array $data Data to preload on object creation
*/
public function __construct($data = null)
{
$this->db = MysqliDb::getInstance();
if (empty($this->dbTable)) {
$this->dbTable = get_class($this);
}
if ($data) {
$this->data = $data;
}
}
示例10: __construct
/**
* @param array $data Data to preload on object creation
*/
public function __construct($data = null)
{
$this->db = MysqliDb::getInstance();
if ($data) {
$this->data = $data;
}
}