本文整理汇总了PHP中Database::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::get方法的具体用法?PHP Database::get怎么用?PHP Database::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_duration_query
function user_duration_query($course_id, $start = false, $end = false, $group = false)
{
$terms = array();
if ($start !== false and $end !== false) {
$date_where = 'AND actions_daily.day BETWEEN ?s AND ?s';
$terms = array($start . ' 00:00:00', $end . ' 23:59:59');
} elseif ($start !== false) {
$date_where = 'AND actions_daily.day > ?s';
$terms[] = $start . ' 00:00:00';
} elseif ($end !== false) {
$date_where = 'AND actions_daily.day < ?s';
$terms[] = $end . ' 23:59:59';
} else {
$date_where = '';
}
if ($group !== false) {
$from = "`group_members` AS groups\n LEFT JOIN user ON groups.user_id = user.id";
$and = "AND groups.group_id = ?d";
$terms[] = $group;
} else {
$from = " (SELECT * FROM user UNION (SELECT 0 as id,\n '' as surname,\n 'Anonymous' as givenname,\n null as username,\n null as password,\n null as email,\n null as parent_email,\n null as status,\n null as phone,\n null as am,\n null as registered_at,\n null as expires_at,\n null as lang, \n null as description,\n null as has_icon,\n null as verified_mail,\n null as receive_mail,\n null as email_public,\n null as phone_public,\n null as am_public,\n null as whitelist,\n null as last_passreminder)) as user ";
$and = '';
}
return Database::get()->queryArray("SELECT SUM(actions_daily.duration) AS duration,\n user.surname AS surname,\n user.givenname AS givenname,\n user.id AS id,\n user.am AS am\n FROM {$from}\n LEFT JOIN actions_daily ON user.id = actions_daily.user_id\n WHERE (actions_daily.course_id = ?d)\n {$and}\n {$date_where}\n GROUP BY user.id\n ORDER BY surname, givenname", $course_id, $terms);
}
示例2: show
function show()
{
if (empty($_POST)) {
HTTP::redirectTo('index.php');
}
$db = Database::get();
$username = HTTP::_GP('username', '', UTF8_SUPPORT);
$password = HTTP::_GP('password', '', true);
$sql = "SELECT id, password FROM %%USERS%% WHERE universe = :universe AND username = :username;";
$loginData = $db->selectSingle($sql, array(':universe' => Universe::current(), ':username' => $username));
if (isset($loginData)) {
$hashedPassword = PlayerUtil::cryptPassword($password);
if ($loginData['password'] != $hashedPassword) {
// Fallback pre 1.7
if ($loginData['password'] == md5($password)) {
$sql = "UPDATE %%USERS%% SET password = :hashedPassword WHERE id = :loginID;";
$db->update($sql, array(':hashedPassword' => $hashedPassword, ':loginID' => $loginData['id']));
} else {
HTTP::redirectTo('index.php?code=1');
}
}
$session = Session::create();
$session->userId = (int) $loginData['id'];
$session->adminAccess = 0;
$session->save();
HTTP::redirectTo('game.php');
} else {
HTTP::redirectTo('index.php?code=1');
}
}
示例3: UpdateOfficier
public function UpdateOfficier($Element)
{
global $USER, $PLANET, $resource, $pricelist;
$costResources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
if (!BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element) || !BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costResources) || $pricelist[$Element]['max'] <= $USER[$resource[$Element]]) {
return;
}
$USER[$resource[$Element]] += 1;
if (isset($costResources[901])) {
$PLANET[$resource[901]] -= $costResources[901];
}
if (isset($costResources[902])) {
$PLANET[$resource[902]] -= $costResources[902];
}
if (isset($costResources[903])) {
$PLANET[$resource[903]] -= $costResources[903];
}
if (isset($costResources[921])) {
$USER[$resource[921]] -= $costResources[921];
}
$sql = 'UPDATE %%USERS%% SET
' . $resource[$Element] . ' = :newTime
WHERE
id = :userId;';
Database::get()->update($sql, array(':newTime' => $USER[$resource[$Element]], ':userId' => $USER['id']));
}
示例4: run
function run()
{
require_once 'includes/classes/class.MissionFunctions.php';
require_once 'includes/classes/missions/Mission.interface.php';
$db = Database::get();
$sql = 'SELECT %%FLEETS%%.*
FROM %%FLEETS_EVENT%%
INNER JOIN %%FLEETS%% ON fleetID = fleet_id
WHERE `lock` = :token;';
$fleetResult = $db->select($sql, array(':token' => $this->token));
foreach ($fleetResult as $fleetRow) {
if (!isset(self::$missionObjPattern[$fleetRow['fleet_mission']])) {
$sql = 'DELETE FROM %%FLEETS%% WHERE fleet_id = :fleetId;';
$db->delete($sql, array(':fleetId' => $fleetRow['fleet_id']));
continue;
}
$missionName = self::$missionObjPattern[$fleetRow['fleet_mission']];
$path = 'includes/classes/missions/' . $missionName . '.class.php';
require_once $path;
/** @var $missionObj Mission */
$missionObj = new $missionName($fleetRow);
switch ($fleetRow['fleet_mess']) {
case 0:
$missionObj->TargetEvent();
break;
case 1:
$missionObj->ReturnEvent();
break;
case 2:
$missionObj->EndStayEvent();
break;
}
}
}
示例5: list_lps
/**
* @brief display list of available learning paths (if any)
* @global type $id
* @global type $course_id
* @global type $tool_content
* @global type $urlServer
* @global type $langComments
* @global type $langAddModulesButton
* @global type $langChoice
* @global type $langNoLearningPath
* @global type $langLearningPaths
* @global type $course_code
*/
function list_lps()
{
global $id, $course_id, $tool_content, $urlServer, $langComments, $langAddModulesButton, $langChoice, $langNoLearningPath, $langLearningPaths, $course_code;
$result = Database::get()->queryArray("SELECT * FROM lp_learnPath WHERE course_id = ?d ORDER BY name", $course_id);
$lpinfo = array();
foreach ($result as $row) {
$lpinfo[] = array('id' => $row->learnPath_id, 'name' => $row->name, 'comment' => $row->comment, 'visible' => $row->visible, 'rank' => $row->rank);
}
if (count($lpinfo) == 0) {
$tool_content .= "<div class='alert alert-warning'>{$langNoLearningPath}</div>";
} else {
$tool_content .= "<form action='insert.php?course={$course_code}' method='post'>" . "<input type='hidden' name='id' value='{$id}'>" . "<table class='table-default'>" . "<tr>" . "<th><div align='left'> {$langLearningPaths}</div></th>" . "<th><div align='left'>{$langComments}</div></th>" . "<th width='80'>{$langChoice}</th>" . "</tr>";
foreach ($lpinfo as $entry) {
if ($entry['visible'] == 0) {
$vis = 'invisible';
} else {
$vis = '';
}
$tool_content .= "<tr class='{$vis}'>";
$tool_content .= "<td> " . icon('fa-ellipsis-h') . " <a href='{$urlServer}/modules/learnPath/learningPath.php?course={$course_code}&path_id={$entry['id']}'>" . q($entry['name']) . "</a></td>";
$tool_content .= "<td>" . q($entry['comment']) . "</td>";
$tool_content .= "<td class='text-center'><input type='checkbox' name='lp[]' value='{$entry['id']}'></td>";
$tool_content .= "</tr>";
}
$tool_content .= "<tr>" . "<th colspan='3'><div align='right'>";
$tool_content .= "<input class='btn btn-primary' type='submit' name='submit_lp' value='{$langAddModulesButton}'></div></th>";
$tool_content .= "</tr></table></form>\n";
}
}
示例6: get_hybridauth_config
function get_hybridauth_config() {
$providers = array (
// openid providers
'OpenID' => array ('enabled' => false));
$q = Database::get()->queryArray("SELECT * FROM auth
WHERE auth_name IN ('yahoo', 'google', 'facebook', 'twitter', 'live', 'linkedin')");
if ($q) {
foreach ($q as $row) {
$name = $row->auth_name == 'linkedin' ? 'LinkedIn' : ucfirst($row->auth_name);
if ($row->auth_default and !empty($row->auth_settings)) {
$providers[$name]['keys'] = unserialize($row->auth_settings);
$providers[$name]['enabled'] = true;
if ($name == 'Facebook') {
$providers[$name]['scope'] = 'public_profile, email';
}
} else {
$providers[$name]['keys'] = array();
$providers[$name]['enabled'] = true;
}
}
}
// return configuration data as an array
return array(
'base_url' => $GLOBALS['urlServer'] . 'modules/auth/methods/hybridauth/',
'providers' => $providers,
// if you want to enable logging, set 'debug_mode' to true then provide a writable file by the web server on 'debug_file'
'debug_mode' => false,
'debug_file' => '/tmp/log.log');
}
示例7: list_exercises
/**
* display list of exercises
* @global type $id
* @global type $course_id
* @global type $tool_content
* @global type $urlServer
* @global type $langComments
* @global type $langAddModulesButton
* @global type $langChoice
* @global type $langNoExercises
* @global type $langExercices
* @global type $course_code
*/
function list_exercises()
{
global $id, $course_id, $tool_content, $urlServer, $langComments, $langAddModulesButton, $langChoice, $langNoExercises, $langExercices, $course_code;
$result = Database::get()->queryArray("SELECT * FROM exercise WHERE course_id = ?d", $course_id);
$quizinfo = array();
foreach ($result as $row) {
$quizinfo[] = array('id' => $row->id, 'name' => $row->title, 'comment' => $row->description, 'visibility' => $row->active);
}
if (count($quizinfo) == 0) {
$tool_content .= "<div class='alert alert-warning'>{$langNoExercises}</div>";
} else {
$tool_content .= "<form action='insert.php?course={$course_code}' method='post'><input type='hidden' name='id' value='{$id}'>" . "<table class='table-default'>" . "<tr>" . "<th width='20%' class='text-left'>{$langExercices}</th>" . "<th class='text-left'>{$langComments}</th>" . "<th>{$langChoice}</th>" . "</tr>";
foreach ($quizinfo as $entry) {
if ($entry['visibility'] == '0') {
$vis = 'not_visible';
} else {
$vis = '';
}
$tool_content .= "<tr class='{$vis}'>";
$tool_content .= "<td class='text-left'><a href='{$urlServer}modules/exercise/exercise_submit.php?course={$course_code}&exerciseId={$entry['id']}'>" . q($entry['name']) . "</a></td>";
$tool_content .= "<td class='text-left'>" . $entry['comment'] . "</td>";
$tool_content .= "<td class='text-center'><input type='checkbox' name='exercise[]' value='{$entry['id']}'></td>";
$tool_content .= "</tr>";
}
$tool_content .= "<tr><th colspan='3'><div align='right'>";
$tool_content .= "<input class='btn btn-primary' type='submit' name='submit_exercise' value='{$langAddModulesButton}'></div></th>";
$tool_content .= "</tr></table></form>";
}
}
示例8: create
/**
* Create a new foreign key from $masterTableName to $detailTableName based
* on the $detailFieldName field
* @param type $detailTableName The detail table name
* @param type $detailFieldName The detail table's field name, which
* connects with the master table
* @param type $masterTableName The master table name
* @param type $defaultEntryResolver A numeric value or a function which
* returns a numeric value, in order to get the master id field value. This
* will be used as default for those entries of the detail table, who are
* orphaned (have a wrong reference). If this value is null, or if the
* function returns null, and the field does not accept null values, then
* the orphaned entries will be removed from the detail table and recycled
* to the recyclebin table.
*/
public static function create($detailTableName, $detailFieldName, $masterTableName, $defaultEntryResolver) {
$masterIDFieldName = DBHelper::primaryKeyOf($masterTableName);
if (DBHelper::foreignKeyExists($detailTableName, $detailFieldName, $masterTableName, $masterIDFieldName))
return;
$detailIDFieldName = DBHelper::primaryKeyOf($detailTableName);
$defaultEntryID = is_null($defaultEntryResolver) ? null :
(is_numeric($defaultEntryResolver) ? $defaultEntryResolver :
is_callable($defaultEntryResolver) ? $defaultEntryResolver() :
null);
$nullable = DBHelper::isColumnNullable($detailTableName, $detailFieldName);
$wrongIDs = Database::get()->queryArray("select `$detailTableName`.`$detailIDFieldName` as detailid from `$detailTableName`
left join `$masterTableName` on `$detailTableName`.`$detailFieldName` = `$masterTableName`.`$masterIDFieldName`
where `$detailTableName`.`$detailFieldName` is not null and `$masterTableName`.`$masterIDFieldName` is null");
if ($wrongIDs) {
foreach ($wrongIDs as $entry) {
if (is_null($defaultEntryID)) {
if ($nullable)
Database::get()->query("update `" . $detailTableName . "` set `" . $detailFieldName . "` = NULL where $detailIDFieldName = ?d"
, $entry->detailid);
else
Recycle::deleteObject($detailTableName, $entry->detailid, $detailIDFieldName);
} else {
Database::get()->query("update `" . $detailTableName . "` set `" . $detailFieldName . "` = ?d where $detailIDFieldName = ?d"
, $defaultEntryID, $entry->detailid);
}
}
}
DBHelper::createForeignKey($detailTableName, $detailFieldName, $masterTableName, $masterIDFieldName);
}
示例9: show
function show()
{
global $LNG, $USER;
$LNG->includeData(array('FLEET'));
$this->setWindow('popup');
$db = Database::get();
$RID = HTTP::_GP('raport', '');
$sql = "SELECT raport,attacker,defender FROM %%RW%% WHERE rid = :reportID;";
$reportData = $db->selectSingle($sql, array(':reportID' => $RID));
if (empty($reportData)) {
$this->printMessage($LNG['sys_raport_not_found']);
}
// empty is BC for pre r2484
$isAttacker = empty($reportData['attacker']) || in_array($USER['id'], explode(",", $reportData['attacker']));
$isDefender = empty($reportData['defender']) || in_array($USER['id'], explode(",", $reportData['defender']));
if (empty($reportData) || !$isAttacker && !$isDefender) {
$this->printMessage($LNG['sys_raport_not_found']);
}
$combatReport = unserialize($reportData['raport']);
if ($isAttacker && !$isDefender && $combatReport['result'] == 'r' && count($combatReport['rounds']) <= 2) {
$this->printMessage($LNG['sys_raport_lost_contact']);
}
$combatReport['time'] = _date($LNG['php_tdformat'], $combatReport['time'], $USER['timezone']);
$combatReport = $this->BCWrapperPreRev2321($combatReport);
$this->assign(array('Raport' => $combatReport, 'pageTitle' => $LNG['sys_mess_attack_report']));
$this->display('shared.mission.raport.tpl');
}
示例10: start
public static function start()
{
$app = Core::make('app');
if ($app->isRunThroughCommandLineInterface()) {
$storage = new MockArraySessionStorage();
} else {
if (Config::get('concrete.session.handler') == 'database') {
$db = \Database::get();
$storage = new NativeSessionStorage(array(), new PdoSessionHandler($db->getWrappedConnection(), array('db_table' => 'Sessions', 'db_id_col' => 'sessionID', 'db_data_col' => 'sessionValue', 'db_time_col' => 'sessionTime')));
} else {
//$storage = new NativeSessionStorage(array(), new NativeFileSessionHandler());
$storage = new NativeSessionStorage(array());
}
$options = Config::get('concrete.session.cookie');
if ($options['cookie_path'] === false) {
$options['cookie_path'] = $app['app_relative_path'] . '/';
}
$options['gc_max_lifetime'] = Config::get('concrete.session.max_lifetime');
$storage->setOptions($options);
}
$session = new SymfonySession($storage);
$session->setName(Config::get('concrete.session.name'));
static::testSessionFixation($session);
return $session;
}
示例11: get_agendaitems
function get_agendaitems($month, $year)
{
global $urlServer, $uid;
if ($month < 10) {
$month = '0' . $month;
}
$query = Database::get()->queryArray("SELECT course.code k, course.public_code fc,\n course.title i, course.prof_names t, course.id id\n FROM course, course_user, course_module\n WHERE course.id = course_user.course_id\n AND course.visible != " . COURSE_INACTIVE . "\n AND course_user.user_id = {$uid}\n AND course_module.module_id = " . MODULE_ID_AGENDA . "\n AND course_module.visible = 1\n AND course_module.course_id = course.id");
$items = array();
foreach ($query as $mycours) {
$result = Database::get()->queryArray("SELECT * FROM agenda WHERE course_id = ?d\n AND DATE_FORMAT(start, '%m') = ?s\n AND DATE_FORMAT(start, '%Y') = ?s\n AND visible = 1", $mycours->id, $month, $year);
foreach ($result as $item) {
$URL = $urlServer . "modules/agenda/index.php?course=" . $mycours->k;
$agendadate = date('d', strtotime($item->start));
$time = date('H:i', strtotime($item->start));
$items[$agendadate][$time] = "<br /><small>({$time}) <a href='{$URL}' title='{$mycours->i} ({$mycours->fc})'>{$mycours->i}</a> {$item->title}</small>";
}
}
// sorting by hour for every day
$agendaitems = array();
while (list($agendadate, $tmpitems) = each($items)) {
sort($tmpitems);
$agendaitems[$agendadate] = '';
while (list($key, $val) = each($tmpitems)) {
$agendaitems[$agendadate] .= $val;
}
}
return $agendaitems;
}
示例12: hybridAuthForm
function hybridAuthForm($auth) {
global $tool_content, $langAuthenticateVia, $langInstructionsAuth;
$r = Database::get()->querySingle("SELECT auth_settings, auth_instructions, auth_name FROM auth WHERE auth_id = ?d", $auth);
if (!empty($r->auth_settings)) {
$auth_settings = unserialize($r->auth_settings);
if (isset($auth_settings['id'])) {
$auth_settings['key'] = $auth_settings['id'];
}
} else {
$auth_settings['id'] = $auth_settings['secret'] = '';
}
$auth_instructions = $r->auth_instructions;
$authName = q(ucfirst($r->auth_name));
$tool_content .= "<div class='alert alert-info'>" . ucfirst($langAuthenticateVia) . " $authName</div>
<div class='form-group'>
<label for='hybridauth_id_key' class='col-sm-2 control-label'>$authName Id/Key:</label>
<div class='col-sm-10'>
<input class='form-control' name='hybridauth_id_key' id='hybridauth_id_key' type='text' value='" . q($auth_settings['key']) . "'>
</div>
</div>
<div class='form-group'>
<label for='hybridauth_secret' class='col-sm-2 control-label'>" . ucfirst($r->auth_name) . " Secret:</label>
<div class='col-sm-10'>
<input class='form-control' name='hybridauth_secret' id='hybridauth_secret' type='text' value='" . q($auth_settings['secret']) . "'>
</div>
</div>
<div class='form-group'>
<label for='auth_instructions' class='col-sm-2 control-label'>$langInstructionsAuth:</label>
<div class='col-sm-10'>
<textarea class='form-control' name='hybridauth_instructions' id='hybridauth_instructions' rows='10'>" . q($auth_instructions) . "</textarea>
</div>
</div>";
}
示例13: ShowTeamspeakPage
function ShowTeamspeakPage()
{
global $LNG;
$config = Config::get(Universe::getEmulated());
if ($_POST) {
$config_before = array('ts_timeout' => $config->ts_timeout, 'ts_modon' => $config->ts_modon, 'ts_server' => $config->ts_server, 'ts_tcpport' => $config->ts_tcpport, 'ts_udpport' => $config->ts_udpport, 'ts_version' => $config->ts_version, 'ts_login' => $config->ts_login, 'ts_password' => $config->ts_password, 'ts_cron_interval' => $config->ts_cron_interval);
$ts_modon = isset($_POST['ts_on']) && $_POST['ts_on'] == 'on' ? 1 : 0;
$ts_server = HTTP::_GP('ts_ip', '');
$ts_tcpport = HTTP::_GP('ts_tcp', 0);
$ts_udpport = HTTP::_GP('ts_udp', 0);
$ts_timeout = HTTP::_GP('ts_to', 0);
$ts_version = HTTP::_GP('ts_v', 0);
$ts_login = HTTP::_GP('ts_login', '');
$ts_password = HTTP::_GP('ts_password', '', true);
$ts_cron_interval = HTTP::_GP('ts_cron', 0);
$config_after = array('ts_timeout' => $ts_timeout, 'ts_modon' => $ts_modon, 'ts_server' => $ts_server, 'ts_tcpport' => $ts_tcpport, 'ts_udpport' => $ts_udpport, 'ts_version' => $ts_version, 'ts_login' => $ts_login, 'ts_password' => $ts_password, 'ts_cron_interval' => $ts_cron_interval);
foreach ($config_after as $key => $value) {
$config->{$key} = $value;
}
$config->save();
$sql = "UPDATE %%CRONJOBS%%\n\t\tSET isActive = :isActive, `lock` = NULL, nextTime = 0\n\t\tWHERE name = 'teamspeak';";
Database::get()->update($sql, array(':isActive' => $ts_modon));
$LOG = new Log(3);
$LOG->target = 4;
$LOG->old = $config_before;
$LOG->new = $config_after;
$LOG->save();
}
$template = new template();
$template->assign_vars(array('se_save_parameters' => $LNG['se_save_parameters'], 'ts_tcpport' => $LNG['ts_tcpport'], 'ts_serverip' => $LNG['ts_serverip'], 'ts_version' => $LNG['ts_version'], 'ts_active' => $LNG['ts_active'], 'ts_settings' => $LNG['ts_settings'], 'ts_udpport' => $LNG['ts_udpport'], 'ts_timeout' => $LNG['ts_timeout'], 'ts_server_query' => $LNG['ts_server_query'], 'ts_sq_login' => $LNG['ts_login'], 'ts_sq_pass' => $LNG['ts_pass'], 'ts_lng_cron' => $LNG['ts_cron'], 'ts_to' => $config->ts_timeout, 'ts_on' => $config->ts_modon, 'ts_ip' => $config->ts_server, 'ts_tcp' => $config->ts_tcpport, 'ts_udp' => $config->ts_udpport, 'ts_v' => $config->ts_version, 'ts_login' => $config->ts_login, 'ts_password' => $config->ts_password, 'ts_cron' => $config->ts_cron_interval));
$template->show('TeamspeakPage.tpl');
}
示例14: __construct
/**
* Create a new instance of the database helper.
*/
public function __construct()
{
/**
* connect to PDO here.
*/
$this->db = Database::get();
}
示例15: usePermissionCollectionIDForIdentifier
public static function usePermissionCollectionIDForIdentifier()
{
static $usePermissionsCollectionID;
if (!isset($usePermissionsCollectionID)) {
// we do this because these five items are known to be OK for caching permissions against
// page IDs (well file_uploader is unrelated but we still need to check for it or it will trip this check.)
// if these are the only things included in your site then you should be able to use permissionsCollectionID for
// checking permissions against, which will dramatically improve performance.
// If you have any custom access entities though you won't be able to use this.
// Obviously a better way of doing this would be to retrieve all access entity types, run through each and see whether
// they support it but this is better for performance.
try {
$db = \Database::get();
$q = "select pal.paID from PagePermissionAssignments ppa inner join PermissionAccessList pal on (ppa.paID = pal.paID) inner join PermissionAccessEntities pae on pal.peID = pae.peID inner join PermissionAccessEntityTypes paet on pae.petID = paet.petID where paet.petHandle not in ('group', 'user', 'group_set', 'group_combination', 'file_uploader')";
$paID = $db->GetOne($q);
if ($paID) {
$usePermissionsCollectionID = false;
} else {
$usePermissionsCollectionID = true;
}
} catch (\Exception $e) {
$usePermissionsCollectionID = false;
}
}
return $usePermissionsCollectionID;
}