本文整理汇总了PHP中DB::getRecord方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::getRecord方法的具体用法?PHP DB::getRecord怎么用?PHP DB::getRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::getRecord方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: total
/**
* Returns the total rows of the presence_users table.
* @return type Integer
*/
protected function total()
{
//get the total count
$sql = "SELECT COUNT(*) as total\n FROM presence_users";
$total = DB::getRecord($sql, array());
return $total->total;
}
示例2: __construct
function __construct($page_id, $action = false, $is_tab = false)
{
$this->id = $page_id;
$this->action = $action;
$this->is_tab = $is_tab;
$this->page_info = DB::getRecord($this->is_tab ? 'admin_tabs' : 'admin_pages', $page_id, 0, 1);
}
示例3: pages
/**
* Returns the number of available pages for a table. 10 rows per page
*
* @return int $pages
*/
public static function pages()
{
$sql = "SELECT COUNT(*) as count\n FROM " . self::table();
$total = DB::getRecord($sql, array());
$total->count % 10 > 0 ? $rest = 1 : ($rest = 0);
return (int) (($total->count - $total->count % 10) / 10) + $rest;
}
示例4: get_range_total
public static function get_range_total($params)
{
$sql = "SELECT SEC_TO_TIME(SUM(timediff)) as total\n\t\t\t\tFROM " . self::table() . "\n\t\t\t\tWHERE timestart BETWEEN ? AND ?\n AND `userid` = ?";
$result = DB::getRecord($sql, array(strtotime($params->dp_start), strtotime($params->dp_end), $params->user));
$result->timestart = $params->dp_start;
$result->timeend = $params->dp_end;
return $result;
}
示例5: getRecord
public static function getRecord($currency_abbr = false, $currency_id = false)
{
if (!$currency_abbr && !$currency_id) {
return false;
}
if ($currency_abbr) {
return DB::getRecord('currencies', false, $currency_abbr, 0, 'currency');
} elseif ($currency_id > 0) {
return DB::getRecord('currencies', $currency_id, false, 1);
}
}
示例6: display
function display()
{
global $CFG;
$tab_id = $CFG->pm_editor ? $CFG->id : Control::getPageId($CFG->url, 1);
if (!$tab_id > 0) {
return false;
}
$current_tab = DB::getRecord('admin_tabs', $tab_id, 0, 1);
$pages = self::getPages($tab_id);
if ($pages) {
$HTML = '
<div class="page_map">';
foreach ($pages as $page) {
if ($CFG->pm_editor) {
$edit = '<a href="#" title="' . $CFG->edit_hover_caption . '" class="edit" class="method_edit_button" onclick="pmPageEdit(' . $page['id'] . ',event);return false;"></a>';
}
$order = $page['order'];
$icon = $page['icon'] ? '<div class="lnk">' . Link::url($page['url'], '<img src="' . $page['icon'] . '" title="' . $page['name'] . '" />', false, false, false, 'content') . '</div>' : '';
$pages_array[$order][] = '
<div class="page_map_page o">
<input type="hidden" id="id" value="' . $page['id'] . '" />
' . $icon . '
<div class="lnk">' . Link::url($page['url'], $page['name'], false, false, false, 'content') . '</div>
' . $edit . '
<div class="clear"></div>
</div>';
}
$total = max(array_keys($pages_array));
$total = $total + count($this->areas_s);
$total = $total + count($this->areas_e);
for ($i = 0; $i <= $total; $i++) {
if ($this->areas_s[$i]) {
foreach ($this->areas_s[$i] as $area) {
$HTML .= $area;
}
}
if ($pages_array[$i]) {
foreach ($pages_array[$i] as $p) {
$HTML .= $p;
}
}
if ($this->areas_e[$i]) {
foreach ($this->areas_e[$i] as $area) {
$HTML .= $area;
}
}
}
$HTML .= '</div>';
} else {
$HTML .= '<div class="no_pages">' . $CFG->pagemap_nothing . '</div>';
}
echo $HTML;
}
示例7: delete
public static function delete($remove_id)
{
global $CFG;
$remove_id = preg_replace("/[^0-9]/", "", $remove_id);
if (!$CFG->session_active || $CFG->session_locked || !($remove_id > 0) || !$CFG->token_verified) {
return false;
}
$existing = DB::getRecord('api_keys', $remove_id, 0, 1);
if (!$existing || $existing['site_user'] != User::$info['id']) {
continue;
}
return db_delete('api_keys', $remove_id);
}
示例8: getRecord
public static function getRecord($currency_abbr = false, $currency_id = false)
{
if (!$currency_abbr && !$currency_id) {
return false;
}
$currency_id1 = preg_replace("/[^0-9]/", "", $currency_id);
$currency_abbr1 = preg_replace("/[^a-zA-Z]/", "", $currency_abbr);
if ($currency_abbr1) {
return DB::getRecord('currencies', false, $currency_abbr1, 0, 'currency');
} elseif ($currency_id1 > 0) {
return DB::getRecord('currencies', $currency_id1, false, 1);
}
}
示例9: login
/**
* Validates the user, and sets the language
*
* @global Object $CONFIG
* @param Array $params
*/
private function login($params)
{
global $CONFIG;
$sql = "SELECT *\n FROM presence_users\n WHERE `identifier` = ?\n AND `password` = ?";
$result = DB::getRecord($sql, array($params['identifier'], sha1($params['password'])));
if ($result) {
$_SESSION['user'] = $result->identifier;
$_SESSION['role'] = $result->role;
//set language
$_SESSION['lang'] = $params['lang'];
RoutingHelper::redirect($CONFIG->wwwroot . '/' . $result->role . '/activity/');
} else {
RoutingHelper::redirect($CONFIG->wwwroot);
}
}
示例10: getRecord
public static function getRecord($braket_id = false, $user = false)
{
global $CFG;
$braket_id = preg_replace("/[^0-9]/", "", $braket_id);
if ($user && !$CFG->session_active) {
return false;
}
if (!($braket_id > 0) && !$user) {
return false;
}
if ($user) {
$braket_id = User::$info['fee_schedule'];
}
return DB::getRecord('fee_schedule', $braket_id, 0, 1);
}
示例11: __construct
function __construct($id, $table, $minimum_increase = false, $place_proxy_bids = false, $anti_sniping_window = false, $anti_sniping_increase = false, $initial_bid = false)
{
$this->id = $id;
$this->table = $table;
$this->proxy_bids = $place_proxy_bids;
$this->anti_sniping = $anti_sniping_window;
$this->anti_sniping_increase = $anti_sniping_increase;
$this->minimum_increase = $minimum_increase ? $minimum_increase : 0.01;
$this->initial_bid = $initial_bid;
$this->item_info = DB::getRecord($this->table, $this->id, false, true);
$this->time_remaining = Auction::getTimeRemaining();
$this->is_expired = $this->time_remaining <= 0;
$this->high_bid = $this->item_info['high_bid'];
$this->high_bid_user_id = $this->item_info['high_bid_user_id'];
$this->now = date('Y-m-d H:i:s', time());
}
示例12: __construct
function __construct($table, $record_id)
{
global $CFG;
$this->table = $table;
$this->record_id = $CFG->include_id > 0 ? $CFG->include_id : $record_id;
$this->row = DB::getRecord($this->table, $this->record_id, 0, 1);
$this->db_fields = DB::getTableFields($this->table);
$this->db_subtables = DB::getSubtables($this->table);
$this->db_subtables = !$this->db_subtables ? array() : $this->db_subtables;
$this->area_i = 0;
$this->current_area = 0;
$page_id = Control::getPageId($CFG->url, $CFG->is_tab);
$corresponding_form = Control::getControls($page_id, 'form', $CFG->is_tab);
if ($corresponding_form) {
$k = key($corresponding_form);
if ($corresponding_form[$k]['params'] = 'Form') {
foreach ($corresponding_form[$k]['methods'] as $method) {
$args = Control::parseArguments($method['arguments'], 'Form', $method['method']);
$name = $args['name'] ? $args['name'] : $args['value'];
$this->form_method_args[$name] = $args;
}
}
}
}
示例13: delete
public static function delete($id = false, $order_log_id = false)
{
global $CFG;
$id = preg_replace("/[^0-9]/", "", $id);
$order_log_id = preg_replace("/[^0-9]/", "", $order_log_id);
if (!($id > 0)) {
$id = $order_log_id;
}
if (!($id > 0)) {
return false;
}
if (!$CFG->session_active) {
return false;
}
if (!$order_log_id) {
$del_order = DB::getRecord('orders', $id, 0, 1);
} else {
$del_order = self::getRecord(false, $order_log_id);
}
if (!$del_order) {
return array('error' => array('message' => 'Order not found.', 'code' => 'ORDER_NOT_FOUND'));
}
if ($del_order['site_user'] != User::$info['id']) {
return array('error' => array('message' => 'User mismatch.', 'code' => 'AUTH_NOT_AUTHORIZED'));
}
self::setStatus(false, 'CANCELLED_USER', $del_order['log_id'], $del_order['btc']);
db_delete('orders', $del_order['id']);
return self::getStatus($del_order['log_id']);
}
示例14:
<div class="tr1_shadow"></div>
<div class="tr2_shadow"></div>
<div class="bl1_shadow"></div>
<div class="bl2_shadow"></div>
<div class="br1_shadow"></div>
<div class="br2_shadow"></div>
<div class="clear"></div>
</div>
</div>';
}
echo '
</div>';
}
}
} else {
$page_info = DB::getRecord($CFG->is_tab ? 'admin_tabs' : 'admin_pages', $CFG->id, 0, 1);
if (!$page_info['is_ctrl_panel'] || $page_info['is_ctrl_panel'] == 'N') {
echo '
<div class="menu_item"><a class="' . (!$CFG->action ? 'high' : false) . '" href="#">' . $CFG->pm_list_tab . '</a></div>
<div class="menu_item"><a class="' . ($CFG->action == 'form' ? 'high' : false) . '" href="#">' . $CFG->pm_form_tab . '</a></div>
<div class="menu_item"><a class="' . ($CFG->action == 'record' ? 'high' : false) . '" href="#">' . $CFG->pm_record_tab . '</a></div>';
} else {
echo '
<div class="menu_item"><a class="' . (!$CFG->action ? 'high' : false) . '" href="#">' . $CFG->pm_ctrl_tab . '</a></div>';
}
echo '
<div class="pm_nav">';
PageMaker::showTabsPages();
echo '
<div class="pm_exit"><div class="pm_exit_icon" onclick="pmExitEditor();"></div> <a href="index.php" onclick="pmExitEditor();return false;">' . $CFG->pm_exit . '</a></div>
</div>';
示例15: show
private function show($comments)
{
global $CFG;
if ($comments) {
echo '<ul>';
foreach ($comments as $comment) {
$elapsed = time() + Settings::mysqlTimeDiff() * 3600 - strtotime($comment['date']);
if ($elapsed < 60) {
$time_ago = $CFG->comments_less_than_minute;
} elseif ($elapsed > 60 && $elapsed < 60 * 60) {
$minutes = floor($elapsed / 60);
$time_ago = str_ireplace('[field]', $minutes, $CFG->comments_minutes_ago);
} elseif ($elapsed > 60 * 60 && $elapsed < 60 * 60 * 24) {
$hours = floor($elapsed / 60 / 60);
$time_ago = str_ireplace('[field]', $hours, $CFG->comments_hours_ago);
} elseif ($elapsed > 60 * 60 * 24 && $elapsed < 60 * 60 * 24 * 30.4) {
$days = floor($elapsed / 60 / 60 / 24);
$time_ago = str_ireplace('[field]', $days, $CFG->comments_days_ago);
} else {
$months = floor($elapsed / 60 / 60 / 24 / 30.4);
$time_ago = str_ireplace('[field]', $months, $CFG->comments_months_ago);
}
if ($comment['user_id'] > 0) {
$user = DB::getRecord($this->user_table, $comment['user_id'], false, true);
$name = !empty($comment['website']) ? Link::url($comment['website'], $user['user']) : $user['user'];
} else {
$name = !empty($comment['website']) ? Link::url($comment['website'], $comment['name']) : $comment['name'];
}
$short = $this->short_version ? '_short' : '';
$icon = $comment['type'] ? eval('return $CFG->comment_type_' . $comment['type'] . ';') : $CFG->comment_type_1;
$action = $comment['type'] ? eval('return $CFG->comments_action_' . $comment['type'] . $short . ';') : $CFG->comments_wrote_label;
$action = String::doFormulaReplacements($action, unserialize($comment['f_table_row']), 1, 1);
echo '
<li id="comment_' . $comment['id'] . '" class="level_' . $comment['type'] . '">
<div class="c_head">';
if ($this->fields) {
foreach ($this->fields as $f_name => $field) {
$CFG->o_method_id = $field['method_id'];
$CFG->o_method_name = 'field';
$record = new Record($field['table'], $comment['record_id']);
echo '<div class="added_field">' . $record->field($field['name'], $field['caption'], $field['subtable'], $field['subtable_fields'], $field['link_url'], $field['concat_char'], true, $field['f_id_field'], $field['order_by'], $field['order_asc'], $comment['record_id'], $field['link_is_tab'], $field['limit_is_curdate'], false, $field['link_id_field']) . '</div>';
}
}
echo '
' . $icon . ' ' . $name . ' (' . $time_ago . ') ' . $action . '
</div>';
if (!$this->short_version) {
echo '
<div class="c_comment">
' . (strlen($comment['comments']) != strlen(strip_tags($comment['comments'])) ? $comment['comments'] : nl2br($comment['comments'])) . '
</div>';
}
echo '
' . ($comment['type'] <= 1 && !$this->short_version ? '<div class="c_reply"><a href="#" onclick="showReplyBox(' . $comment['id'] . ',' . $this->i . ');return false;">' . $CFG->comments_reply_label . '</a></div>' : '') . '
<div class="c_form"></div>
</li>';
if (is_array($comment['children'])) {
Comments::show($comment['children']);
}
}
echo '<div style="clear:both;height:0;"></div></ul>';
}
}