本文整理汇总了PHP中Db::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Db::get方法的具体用法?PHP Db::get怎么用?PHP Db::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db
的用法示例。
在下文中一共展示了Db::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
function login()
{
if (!empty($_POST)) {
$check = new Check();
$user = new User();
$pdo = new Db();
$db = $pdo->get();
$mapper = new Mapper($db);
//Проверяем входные данные
$user->login = $check->checkInput($_POST['login']);
$password = $check->checkInput($_POST['pass']);
$user->password = md5($password);
//Если пользователь не найден
$this->user = $mapper->select($user);
if (empty($this->user)) {
$this->error = "Пароль или логин не совпадают";
$this->out('login.php');
} else {
$this->out('profile.php');
//Если найден, выводим профиль
}
} else {
$this->out('login.php');
}
}
示例2: init
function init($host)
{
$this->host = $host;
$this->dbh = Db::get();
$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
$host->add_hook($host::HOOK_PREFS_TAB, $this);
}
示例3: enumerate
public function enumerate($spid = null, $include = self::ALL)
{
$rawList = Db::get()->getResultSet("SELECT * FROM elenco_programmi()");
if (!($include & self::POWEROFF)) {
unset($rawList[0]);
}
if (!($include & self::ANTIFREEZE)) {
unset($rawList[1]);
}
if (!($include & self::MANUAL)) {
array_pop($rawList);
}
$this->list = [];
$selected = null;
foreach ($rawList as $v) {
$k = $v['id_programma'];
$this->list[$k] = $v;
if ($selected === null && $spid == $k) {
$this->list[$k]['selected'] = 'selected';
$selected = $k;
} else {
$this->list[$k]['selected'] = '';
}
}
if ($selected === null && $this->list) {
$selected = key($this->list);
$this->list[$selected]['selected'] = 'selected';
}
return $selected;
}
示例4: init
/**
* Init
*
* @param PluginHost $host
*/
function init($host)
{
require_once "PhCURL.php";
$this->host = $host;
$this->dbh = Db::get();
$host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this);
$host->add_hook($host::HOOK_PREFS_TAB, $this);
}
示例5: log
/**
* Logs an activity.
* @param string $activity
* @param string $data
*/
public static function log($activity, $data = null)
{
$db = Db::get();
$data = Db::escape(json_encode($data));
if (ENABLE_AUDIT_TRAILS === true && class_exists("SystemAuditTrailModel", false)) {
SystemAuditTrailModel::log(array('item_id' => 0, 'item_type' => 'system_activity', 'description' => $activity, 'type' => SystemAuditTrailModel::AUDIT_TYPE_SYSTEM));
}
}
示例6: __construct
function __construct()
{
$this->dbh = Db::get();
$this->cache = array();
if ($_SESSION["uid"]) {
$this->cache();
}
}
示例7: __construct
public function __construct($id)
{
if (empty($id)) {
throw new \InvalidArgumentException('Enter User ID');
}
$this->id = $id;
$this->db = Db::get();
}
示例8: addData
public static function addData($data)
{
$pdo = Db::get();
$statement = $pdo->prepare("INSERT INTO common.binary_objects(data) VALUES(?)");
$statement->bindParam(1, $data, PDO::PARAM_LOB);
$statement->execute();
$id = Db::query("SELECT LASTVAL()");
return $id[0]['lastval'];
}
示例9: savelike
function savelike($like, $itemid)
{
$pdo = new Db();
$db = $pdo->get();
$mapper = new Mapper($db);
$comments = new Comments();
$comments->likes = $like;
$comments->id = $itemid;
$mapper->saveLike($comments);
}
示例10: enumerate
public function enumerate($selected = 0)
{
$selected != $this->selected && ($this->selected = $selected);
$this->list = [];
foreach (Db::get()->getResultSet("SELECT id, nome FROM driver_sensori") as $v) {
$k = $v['id'];
$this->list[$k] = $v;
$this->list[$k]['selected'] = $selected == $k ? 'selected' : '';
}
}
示例11: enumerate
public function enumerate($status = self::ALL, $selected = 0)
{
$selected != $this->selected && ($this->selected = $selected);
$status != $this->status && ($this->status = $status);
$this->list = [];
foreach (Db::get()->getResultSet("SELECT * FROM elenco_sensori(:status)", [':status' => $status]) as $v) {
$k = $v['id'];
$this->list[$k] = $v;
$this->list[$k]['selected'] = $selected == $k ? 'selected' : '';
}
}
示例12: settings
/**
* Install the application
*/
public function settings()
{
$form = new Form(array('id' => 'install-settings-form', 'labelWidth' => '30em', 'fieldsets' => array('global' => array('legend' => Lang::get('install.settings-global-legend', null, null, $this->language), new TextInput(array('name' => 'title', 'required' => true, 'label' => Lang::get('install.settings-title-label', null, null, $this->language), 'default' => DEFAULT_HTML_TITLE)), new TextInput(array('name' => 'rooturl', 'required' => true, 'label' => Lang::get('install.settings-rooturl-label', null, null, $this->language), 'placeholder' => 'http://', 'default' => getenv('REQUEST_SCHEME') . '://' . getenv('SERVER_NAME'))), new SelectInput(array('name' => 'timezone', 'required' => true, 'options' => array_combine(\DateTimeZone::listIdentifiers(), \DateTimeZone::listIdentifiers()), 'default' => DEFAULT_TIMEZONE, 'label' => Lang::get('install.settings-timezone-label')))), 'database' => array('legend' => Lang::get('install.settings-database-legend', null, null, $this->language), new TextInput(array('name' => 'db[host]', 'required' => true, 'label' => Lang::get('install.settings-db-host-label', null, null, $this->language), 'default' => 'localhost')), new TextInput(array('name' => 'db[username]', 'required' => true, 'label' => Lang::get('install.settings-db-username-label', null, null, $this->language))), new PasswordInput(array('name' => 'db[password]', 'required' => true, 'label' => Lang::get('install.settings-db-password-label', null, null, $this->language), 'pattern' => '/^.*$/')), new TextInput(array('name' => 'db[dbname]', 'required' => true, 'pattern' => '/^\\w+$/', 'label' => Lang::get('install.settings-db-dbname-label', null, null, $this->language))), new TextInput(array('name' => 'db[prefix]', 'default' => 'Hawk', 'pattern' => '/^\\w+$/', 'label' => Lang::get('install.settings-db-prefix-label', null, null, $this->language)))), 'admin' => array('legend' => Lang::get('install.settings-admin-legend', null, null, $this->language), new TextInput(array('name' => 'admin[login]', 'required' => true, 'pattern' => '/^\\w+$/', 'label' => Lang::get('install.settings-admin-login-label', null, null, $this->language))), new EmailInput(array('name' => 'admin[email]', 'required' => true, 'label' => Lang::get('install.settings-admin-email-label', null, null, $this->language))), new PasswordInput(array('name' => 'admin[password]', 'required' => true, 'label' => Lang::get('install.settings-admin-password-label', null, null, $this->language))), new PasswordInput(array('name' => 'admin[passagain]', 'required' => true, 'compare' => 'admin[password]', 'label' => Lang::get('install.settings-admin-passagain-label', null, null, $this->language)))), '_submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get('install.install-button', null, null, $this->language), 'icon' => 'cog')))), 'onsuccess' => 'location.href = data.rooturl;'));
if (!$form->submitted()) {
// Display the form
$body = View::make(Plugin::current()->getView('settings.tpl'), array('form' => $form));
return \Hawk\Plugins\Main\MainController::getInstance()->index($body);
} else {
// Make the installation
if ($form->check()) {
/**
* Generate Crypto constants
*/
$salt = Crypto::generateKey(24);
$key = Crypto::generateKey(32);
$iv = Crypto::generateKey(16);
$configMode = 'prod';
/**
* Create the database and it tables
*/
$tmpfile = tempnam(sys_get_temp_dir(), '');
DB::add('tmp', array(array('host' => $form->getData('db[host]'), 'username' => $form->getData('db[username]'), 'password' => $form->getData('db[password]'))));
try {
DB::get('tmp');
} catch (DBException $e) {
return $form->response(Form::STATUS_ERROR, Lang::get('install.install-connection-error'));
}
try {
$param = array('{{ $dbname }}' => $form->getData('db[dbname]'), '{{ $prefix }}' => $form->getData('db[prefix]'), '{{ $language }}' => $this->language, '{{ $timezone }}' => $form->getData('timezone'), '{{ $title }}' => Db::get('tmp')->quote($form->getData('title')), '{{ $email }}' => Db::get('tmp')->quote($form->getData('admin[email]')), '{{ $login }}' => Db::get('tmp')->quote($form->getData('admin[login]')), '{{ $password }}' => Db::get('tmp')->quote(Crypto::saltHash($form->getData('admin[password]'), $salt)), '{{ $ip }}' => Db::get('tmp')->quote(App::request()->clientIp()));
$sql = strtr(file_get_contents(Plugin::current()->getRootDir() . 'templates/install.sql.tpl'), $param);
// file_put_contents($tmpfile, $sql);
Db::get('tmp')->query($sql);
/**
* Create the config file
*/
$param = array('{{ $salt }}' => addcslashes($salt, "'"), '{{ $key }}' => addcslashes($key, "'"), '{{ $iv }}' => addcslashes($iv, "'"), '{{ $configMode }}' => $configMode, '{{ $rooturl }}' => $form->getData('rooturl'), '{{ $host }}' => $form->getData('db[host]'), '{{ $username }}' => $form->getData('db[username]'), '{{ $password }}' => $form->getData('db[password]'), '{{ $dbname }}' => $form->getData('db[dbname]'), '{{ $prefix }}' => $form->getData('db[prefix]'), '{{ $sessionEngine }}' => $form->getData('session'), '{{ $version }}' => $form->getData('version'));
$config = strtr(file_get_contents(Plugin::current()->getRootDir() . 'templates/config.php.tpl'), $param);
file_put_contents(INCLUDES_DIR . 'config.php', $config);
/**
* Create etc/dev.php
*/
App::fs()->copy(Plugin::current()->getRootDir() . 'templates/etc-dev.php', ETC_DIR . 'dev.php');
/**
* Create etc/prod.php
*/
App::fs()->copy(Plugin::current()->getRootDir() . 'templates/etc-prod.php', ETC_DIR . 'prod.php');
$form->addReturn('rooturl', $form->getData('rooturl'));
return $form->response(Form::STATUS_SUCCESS, Lang::get('install.install-success'));
} catch (\Exception $e) {
return $form->response(Form::STATUS_ERROR, Lang::get('install.install-error'));
}
}
}
}
示例13: init
function init($host)
{
require_once __DIR__ . "/lib/class.naivebayesian.php";
//require_once __DIR__ . "/lib/class.naivebayesian_ngram.php";
require_once __DIR__ . "/lib/class.naivebayesianstorage.php";
$this->host = $host;
$this->dbh = Db::get();
$this->init_database();
$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
$host->add_hook($host::HOOK_PREFS_TAB, $this);
$host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
}
示例14: getAclResources
public function getAclResources($id)
{
$res = Db::get("SELECT * FROM [prefix]user_groups_to_acl_resources WHERE `user-group-id`=:userGroupId", array(':userGroupId' => $id));
$groups = array();
if ($res !== false) {
if (count($res) > 0) {
foreach ($res as $row) {
$groups[] = $row['acl-resource-id'];
}
}
}
return $groups;
}
示例15: log_error
function log_error($errno, $errstr, $file, $line, $context)
{
if (Db::get() && get_schema_version() > 117) {
$errno = Db::get()->escape_string($errno);
$errstr = Db::get()->escape_string($errstr);
$file = Db::get()->escape_string($file);
$line = Db::get()->escape_string($line);
$context = DB::get()->escape_string($context);
$owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : "NULL";
$result = Db::get()->query("INSERT INTO ttrss_error_log\n\t\t\t\t(errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES\n\t\t\t\t({$errno}, '{$errstr}', '{$file}', '{$line}', '{$context}', {$owner_uid}, NOW())");
return Db::get()->affected_rows($result) != 0;
}
return false;
}