本文整理汇总了PHP中Mysql::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Mysql::init方法的具体用法?PHP Mysql::init怎么用?PHP Mysql::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mysql
的用法示例。
在下文中一共展示了Mysql::init方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
* @param int | dbPrimaryKey , if not, param = false
* @param string | dbConfig , if emptu = "default"
*/
public function __construct($dbPrimaryKey = false, $dbConfigName = "default")
{
self::$db = Mysql::init($dbPrimaryKey, $dbConfigName);
self::$db->setCharset("UTF8");
if ($dbPrimaryKey) {
if ($tmpRow = $this->fetchRow($dbPrimaryKey)) {
foreach ($tmpRow as $key => $value) {
// $this->attributes[$key] = $value;
$this->{$key} = $value;
}
} else {
foreach ($this->fields as $key => $value) {
// $this->attributes[$key] = false;
$this->{$key} = false;
}
}
}
}
示例2: init
/**
* Instance creator.
*
* @param string $vendor
* @return Application\Database\Vendor\{Mysql, Couch, Mongo}
* @throws \Exception
*/
public static final function init(string $vendor)
{
if (isset(self::$instances[$vendor])) {
return self::$instances[$vendor];
}
$app = app();
$cfg = $app->config->get('db');
if (!isset($cfg[$vendor][$app->env])) {
throw new \Exception("`{$vendor}` options not found in config!");
}
switch ($vendor) {
// only mysql for now
case self::VENDOR_MYSQL:
self::$instances[$vendor] = Mysql::init($cfg[$vendor][$app->env]);
break;
default:
throw new \Exception('Unimplemented vendor given!');
}
return self::$instances[$vendor];
}
示例3: init
/**
* Init.
* @param string $vendor
* @return Froq\Database\Vendor\VendorInterface
*/
public static final function init(string $vendor) : VendorInterface
{
if (!isset(self::$instances[$vendor])) {
$app = app();
$appEnv = $app->env;
$appConfig = $app->config;
$cfg = $appConfig['db'];
if (!isset($cfg[$vendor][$appEnv])) {
throw new DatabaseException("'{$vendor}' options not found for '{$appEnv}' env in config!");
}
switch ($vendor) {
// only mysql for now
case self::VENDOR_MYSQL:
self::$instances[$vendor] = Mysql::init($cfg[$vendor][$appEnv]);
break;
default:
throw new DatabaseException('Unimplemented vendor given!');
}
}
return self::$instances[$vendor];
}
示例4: set_log
function set_log($message, $type)
{
$DB = Mysql::init();
$data = array('id' => null, 'type' => $type, 'user_id' => isset($_SESSION['user_data']['id']) ? $_SESSION['user_data']['id'] : 0, 'message' => $DB->escape($message), 'date' => date('Y-m-d H:i:s'));
return $DB->insert(ACCOUNT_DATABASE . '.site_logs', $data);
}
示例5:
<?php
$CFG->load('database');
$DB = Mysql::init($CFG->get('mysql_host'), $CFG->get('mysql_user'), $CFG->get('mysql_password'), $CFG->get('mysql_database'));
$DB->set_names();
Registry::init()->set('DB', $DB);
$CFG->unload('database');
示例6: exit
<?php
if (!defined('BASEPATH')) {
exit('Nu poti accesa acest fisier direct.');
}
set_title(site_name() . ' - Parola depozit');
$DB = Mysql::init();
check_login();
$step = 'request';
if (isset($_POST['sendStoragePassword'])) {
$data = $DB->select("id, login, email", ACCOUNT_DATABASE . ".account", "`id`='" . $_SESSION['user_data']['id'] . "'");
if (is_array($data)) {
$storage_pass = $DB->select('password', PLAYER_DATABASE . '.safebox', "`account_id`='" . $_SESSION['user_data']['id'] . "'");
if ($storage_pass == '') {
$step = 'error';
} else {
// trimitem email
$arr = array('login' => $data['login'], 'password' => $storage_pass['password'], 'site_name' => site_name(), 'site_url' => site_url());
$email_ses = email()->load('passwordlost/storagepassword');
$email_ses->assign($arr);
$email_ses->set('noreply@' . rtrim(site_name(), '/'), '', $data['email'], 'Metin2 - Parola Depozit');
$email_ses->send();
$step = 'sent';
}
}
}
assign('content_tpl', 'content/storagepassword/' . $step);
示例7: connection
public function connection()
{
return Mysql::init();
}