当前位置: 首页>>代码示例>>PHP>>正文


PHP mysql::init方法代码示例

本文整理汇总了PHP中mysql::init方法的典型用法代码示例。如果您正苦于以下问题:PHP mysql::init方法的具体用法?PHP mysql::init怎么用?PHP mysql::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysql的用法示例。


在下文中一共展示了mysql::init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * construct
  * 
  * @uses sets all parameters required by mysql class
  */
 public function __construct()
 {
     if (!empty($this->table)) {
         mysql::init();
         mysql::$table = $this->table;
     }
     if (!empty($this->hasOne)) {
         mysql::$hasOne = $this->hasOne;
     }
     if (!empty($this->hasMany)) {
         mysql::$hasMany = $this->hasMany;
     }
 }
开发者ID:akvlko,项目名称:api,代码行数:18,代码来源:base.php

示例2: mysql

 $environement = !empty($_POST['connect']) && ($_POST['connect'] == 'dev' || $_POST['connect'] == 'prod') ? $_POST['connect'] : 'dev';
 # Tentative de connexion à la base de données
 $con_id = mysqli_connect(${$environement . '_host'}, ${$environement . '_user'}, ${$environement . '_password'});
 if (!$con_id) {
     $errors->set('MySQL: ' . mysqli_connect_errno() . ' ' . mysqli_connect_error());
 } else {
     mysqli_query($con_id, "CREATE DATABASE IF NOT EXISTS " . ${$environement . '_database'});
     $db = mysqli_select_db($con_id, ${$environement . '_database'});
     if (!$db) {
         $errors->set('MySQL: ' . mysqli_errno($con_id) . ' ' . mysqli_error($con_id));
     }
     mysqli_close($con_id);
 }
 if ($errors->isEmpty()) {
     $db = new mysql();
     $db->init(${$environement . '_user'}, ${$environement . '_password'}, ${$environement . '_host'}, ${$environement . '_database'});
     if ($db->error()) {
         $errors->set($db->error());
     } else {
         # Création du fichier de configuration
         $configfile = OKT_CONFIG_PATH . '/connexion.php';
         $config = implode('', (array) file($configfile . '.in'));
         $config = str_replace('%%DB_PROD_HOST%%', $prod_host, $config);
         $config = str_replace('%%DB_PROD_USER%%', $prod_user, $config);
         $config = str_replace('%%DB_PROD_PASS%%', $prod_password, $config);
         $config = str_replace('%%DB_PROD_BASE%%', $prod_database, $config);
         $config = str_replace('%%DB_PROD_PREFIX%%', $prod_prefix, $config);
         $config = str_replace('%%DB_DEV_HOST%%', $dev_host, $config);
         $config = str_replace('%%DB_DEV_USER%%', $dev_user, $config);
         $config = str_replace('%%DB_DEV_PASS%%', $dev_password, $config);
         $config = str_replace('%%DB_DEV_BASE%%', $dev_database, $config);
开发者ID:jewelhuq,项目名称:okatea,代码行数:31,代码来源:db_conf.php

示例3: update_actiontime

$_PHP = array();
$_PHP['magic_quotes_qpc'] = get_magic_quotes_gpc();
//PHP環境處理
if ($_PHP['magic_quotes_qpc']) {
    foreach ($_GET as $k => $v) {
        $_GET[$k] = stripslashes($v);
    }
    foreach ($_POST as $k => $v) {
        $_POST[$k] = stripslashes($v);
    }
}
if (!Cache::init($config['cache'])) {
    die('快取讀取失敗');
}
$db = new mysql();
if (!$db->init($config['dbhost'], $config['dbuser'], $config['dbpass'], $config['dbname'])) {
    die('資料庫連線失敗');
}
$user = false;
if (isset($_COOKIE['uid']) && isset($_COOKIE['sid'])) {
    if ($query = $db->get_one('SELECT `online_user`.*, `user`.* FROM `online_user`, `user` WHERE `online_user`.`sid`=\'' . mysql_real_escape_string($_COOKIE['sid']) . '\' AND `online_user`.`uid`=`user`.`uid`;')) {
        if ($query['lastactiontime'] <= $time + $config['loginexpire'] && $query['uid'] && $query['uid'] == $_COOKIE['uid'] && $_SERVER['REMOTE_ADDR'] == $query['ip']) {
            $user = array('uid' => $query['uid'], 'sid' => $query['sid'], 'username' => $query['username'], 'channel' => $query['channel'], 'ip' => $query['ip'], 'lastmsgid' => $query['lastmsgid']);
            setcookie('uid', $_COOKIE['uid'], $time + $config['loginexpire']);
            setcookie('sid', $_COOKIE['sid'], $time + $config['loginexpire']);
            $db->query('UPDATE FROM `online_user` SET `lastactiontime`=' . $time . ' WHERE `sid`=\'' . $query['sid'] . '\';');
        }
    }
}
function update_actiontime()
{
开发者ID:a0000778,项目名称:chat1,代码行数:31,代码来源:core.inc.php


注:本文中的mysql::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。