本文整理汇总了PHP中table::load方法的典型用法代码示例。如果您正苦于以下问题:PHP table::load方法的具体用法?PHP table::load怎么用?PHP table::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table
的用法示例。
在下文中一共展示了table::load方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pay
public function pay($code, $userId)
{
if (preg_match("/^\\d{" . $this->codeLength . "}\$/", $code)) {
$usersTable = new table('user');
$cardmatch = $this->table->load("WHERE activated=0 AND code='{$code}'");
$usermatch = $usersTable->load("WHERE id={$userId}");
c(" WHERE activated=1 AND code='{$code}'");
c($userId);
if (count($usermatch) == 1 && count($cardmatch) == 1) {
c(42);
$card = $cardmatch[0];
$user = $usermatch[0];
$paySum = intval($card['value']);
$usersTable->edit(array('id' => $userId, 'cash' => intval($user['cash']) + $paySum));
$this->table->edit(array('id' => $card['id'], 'activated' => 1, 'activationdate' => date("Y-m-d H:i:s"), 'user' => $userId));
return $paySum;
} else {
l('payment', 'badscratchcard', NULL, $userId, NULL, array());
}
return false;
}
}
示例2: getCoveredMonths
private function getCoveredMonths()
{
$moneyflowTable = new table('moneyflow');
$rows = $moneyflowTable->load('LIMIT 1');
if ($rows && count($rows)) {
$coveredMonths = array();
$firstEntry = $rows[0];
$startDate = new DateTime($firstEntry['date']);
$currentDate = new DateTime();
$startDate->modify("midnight");
$startDate->setDate($startDate->format('Y'), $startDate->format('m'), 1);
$currentDate->modify("midnight");
$currentDate->setDate($currentDate->format('Y'), $currentDate->format('m'), 1);
do {
$coveredMonths[] = clone $startDate;
$startDate->modify('1 month');
} while ($startDate <= $currentDate);
return $coveredMonths;
} else {
return false;
}
}
示例3: redirect
} else {
if (!$user->isEnabled()) {
redirect('disabled.php');
} else {
if ($user->isRestricted()) {
redirect("/login.php?userisrestricted=true");
} else {
$moneyflowTable = new table('moneyflow');
$orderTable = new table('order');
$ordersRows = $orderTable->load("WHERE user=" . $user->getId());
$orders = array();
for ($i = 0; $i < count($ordersRows); $i++) {
$orders[$ordersRows[$i]['id']] = $ordersRows[$i];
}
$tariffTable = new table('tariff');
$tariffsRows = $tariffTable->load();
$tariffs = array();
for ($i = 0; $i < count($tariffsRows); $i++) {
$tariffs[$tariffsRows[$i]['id']] = $tariffsRows[$i];
}
$rows = $moneyflowTable->load("WHERE user=" . $user->getId() . " ORDER BY `id` DESC");
$loadedUsers = array();
foreach ($rows as $key => $row) {
$paymentDate = new DateTime($row['date']);
$rows[$key]['date'] = $paymentDate->format($timeDateFormat);
$rows[$key]['sum'] = formatCash($row['sum']);
if ($row['name']) {
$rows[$key]['details'] = $row['name'];
} else {
switch ($row['detailsname']) {
case 'scratchcard':
示例4: getAvailableTariffs
function getAvailableTariffs()
{
$tariffTable = new table('tariff');
$allTariffs = $tariffTable->load();
$availableTariffs = array();
$userCity = $this->data['city'];
for ($i = 0; $i < count($allTariffs); $i++) {
$tariff = $allTariffs[$i];
if (in_array($userCity, $tariff['city']) && $tariff['public'] === 1) {
$availableTariffs[$tariff['id']] = $tariff;
}
}
return $availableTariffs;
}
示例5: export
public function export()
{
if ($this->connected) {
$usersTable = new table('user');
$res = $usersTable->load(" WHERE router=" . $this->id);
if ($res) {
foreach ($res as $row) {
$this->update($row['id']);
}
return $this->checkConnection();
}
}
}
示例6: getData
public function getData()
{
global $mysqlTimeDateFormat, $sessionId;
$data = array("total" => 0, "scratchcard" => 0, "adminpay" => array("total" => 0, "byadmin" => array()));
$masterTable = new table('master');
$master = $masterTable->loadById($sessionId);
$permittedCities = $master['city'];
$permittedStreets = $master['street'];
$permittedGroups = $master['usergroup'];
$admins = $masterTable->load();
for ($i = 0; $i < count($admins); $i++) {
$data['adminpay']['byadmin'][$admins[$i]['id']] = 0;
}
$currentTime = new DateTime();
$moneyflowTable = new table('moneyflow');
$startDate = clone $this->month;
$endDate = clone $this->month;
$endDate->modify('1 month');
$endDate->modify('-1 second');
$offsetDays = configgetvalue('system', 'statistics', null, 'paymentsOffset');
$startDate->modify($offsetDays . ' day');
$endDate->modify($offsetDays . ' day');
$condition = "WHERE `date`>='" . $startDate->format($mysqlTimeDateFormat) . "' AND `date`<='" . $endDate->format($mysqlTimeDateFormat) . "' AND (`detailsname`='adminpay' OR `detailsname`='scratchcard') AND `sum`>0";
if (pluginExists('grouprestrict') && $permittedGroups) {
$condition .= " AND ( `user` IN (SELECT `id` FROM `user` WHERE `usergroup` IN (" . join($permittedGroups, ",") . ") ) )";
}
$rows = $moneyflowTable->load($condition);
foreach ($rows as $row) {
$sum = $row['sum'];
$data['total'] += $sum;
if ($row['detailsname'] === 'adminpay') {
$data['adminpay']['total'] += $sum;
if (!isset($data['adminpay']['byadmin'][$row['detailsid']])) {
$data['adminpay']['byadmin'][$row['detailsid']] = 0;
}
$data['adminpay']['byadmin'][$row['detailsid']] += $sum;
} else {
$data['scratchcard'] += $sum;
}
}
$lastRow = end($rows);
configsetvalue('var', 'cache', null, 'int', $this->fileName, $lastRow['id']);
return json_encode($data);
}
示例7: table
<?php
require_once "../include/core.php";
$routersTable = new table('router');
$rows = $routersTable->load();
foreach ($rows as $row) {
controllerRouter($row['id'], 'export', false);
}
示例8: table
break;
case 'getacl':
$masterTable = new table('master');
$master = $masterTable->loadById($sessionId);
$userGroupId = $master['group'];
$groupTable = new table('group');
$group = $groupTable->loadById($userGroupId);
$userAcl = json_decode($group['acl'], true);
$response = $userAcl;
break;
case 'getstatimage':
if (checkPermission($sessionId, array('statistics'))) {
$routerId = $_GET['router'];
$path = str_replace(' ', '%20', $_GET['path']);
$routerTable = new table('router');
$res = $routerTable->load("WHERE id={$routerId}");
if ($row = $res[0]) {
$address = $row['ip'];
$port = configgetvalue('router', 'main', $routerId, 'statPort');
$url = "http://{$address}:{$port}/{$path}.gif";
header("Content-Type:image/gif");
$img = file_get_contents($url);
header("Content-Length:" . strlen($img));
echo $img;
}
}
return;
break;
case 'configedit':
//function configedit($response, $type, $path, $ownerid, $name, $value)
$type = $_GET['type'];
示例9: redirect
if (!$user->isValid()) {
redirect('login.php');
} else {
if (!$user->isEnabled()) {
redirect('disabled.php');
} else {
function markAsRead($id)
{
}
$messageTable = new table('message');
$action = isset($_GET['action']) ? $_GET['action'] : 'notset';
switch ($action) {
case 'list':
$request = "WHERE (`sender`=" . $user->getId() . " AND `sender_is_admin`=0) OR ";
$request .= "(`recipient`=" . $user->getId() . " AND `recipient_is_admin`=0)";
$messages = $messageTable->load($request);
foreach ($messages as $key => $message) {
if ($message['recipient'] === $user->getId() && $message['recipient_is_admin'] === 0) {
$messages[$key]['incoming'] = true;
} else {
$messages[$key]['incoming'] = false;
}
}
$tpl = array("messages" => $messages);
$fenom->display($theme->getTemplateLocation('header.tpl'), $headerData);
$fenom->display($theme->getTemplateLocation('messageslist.tpl'), $tpl);
$fenom->display($theme->getTemplateLocation('footer.tpl'));
break;
case 'show':
case 'showredirect':
$messageId = isset($_GET['id']) ? intval($_GET['id']) : 0;
示例10: sprintf
$speedPostfix = $result[2];
$speedPattern = "%d {$speedPostfix}bit/s";
return sprintf(__($speedPattern), $speedAsNumber);
} else {
return '';
}
}
if (isset($_GET['city']) && intval($_GET['city'])) {
$selectedCity = intval($_GET['city']);
} else {
$selectedCity = 0;
}
$tariffsTable = new table('tariff');
$tariffs = $tariffsTable->load();
$citiesTable = new table('city');
$cities = $citiesTable->load(" ORDER BY `name` ASC");
$tariffsById = array();
$tariffsByCities = array();
$citiesById = array();
// Prepare array for each city
foreach ($cities as $city) {
$cityId = $city['id'];
$tariffsByCities[$cityId] = array();
$citiesById[$cityId] = $city;
}
foreach ($tariffs as $tariff) {
$tariffsById[$tariff['id']] = $tariff;
}
if ($user->isValid() && $user->getField('city') && configgetvalue('system', 'ucp', NULL, 'showTariffsOnlyFromUsersCity')) {
$checkCity = true;
} else {