本文整理汇总了PHP中table::edit方法的典型用法代码示例。如果您正苦于以下问题:PHP table::edit方法的具体用法?PHP table::edit怎么用?PHP table::edit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table
的用法示例。
在下文中一共展示了table::edit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: payment
function payment($mode, $id = false)
{
global $db;
global $mysqlTimeDateFormat;
/*
$mode
0 payment: new cash value will be written, 'upd' action on routers
1 shownotification: new cash value will not be writtent, 'shownotify' on routers
2 clearnotifications: 'clearnotify' on all routers
*/
if ($mode !== 2) {
if ($res = $db->query("SELECT id, price FROM " . DB_TABLE_PREFIX . "tariff")->fetchAll()) {
$price = array();
foreach ($res as $row) {
$price[$row['id']] = $row['price'];
}
}
$typeOfCalculation = configgetvalue('system', 'cash', NULL, 'typeOfCalculation');
$creditMonths = configgetvalue('system', 'cash', NULL, 'creditMonths');
$routerAction = $mode ? "shownotification" : "update";
$usersTable = new table('user');
$usersRes = $usersTable->load($id ? "WHERE id={$id}" : "");
foreach ($usersRes as $row) {
if (!isset($price[$row['tariff']])) {
continue;
}
$tariffId = $row['tariff'];
$userId = $row['id'];
// Calculate amounts
$cash = money($row['cash']);
$sum = -getCashToPay($userId, $row, $price[$tariffId]);
$fullMonthSum = -getCashToPay($userId, $row, $price[$tariffId], true);
$newCash = $cash + $sum;
$minimumCash = $fullMonthSum * intval($creditMonths);
$currentOrder = getCurrentTariff($userId);
if ($mode == 0) {
if ($row['disabled'] == '0' && (!$currentOrder || $currentOrder['temp'] == 1) && ($newCash >= $minimumCash || $row['credit'] == '1')) {
//Add info to payments table
$orderTable = new table('order');
$moneyFlowTable = new table('moneyflow');
$currentDate = new DateTime('midnight');
$startDate = new DateTime('first day of this month midnight');
$endDate = new DateTime('first day of next month midnight');
$endDate->modify("-1 sec");
$withdrawalDay = configgetvalue('system', 'cash', NULL, 'withdrawalDay');
$withdrawalDay -= 1;
if ($withdrawalDay) {
$startDate->modify("+{$withdrawalDay} day");
$endDate->modify("+{$withdrawalDay} day");
}
if ($currentDate < $startDate) {
$startDate->modify("-1 month");
$endDate->modify("-1 month");
}
if ($currentOrder) {
$orderTable->edit(array('id' => $currentOrder['id'], 'canceled' => 1, 'enddate' => $currentDate->format($mysqlTimeDateFormat)));
}
$orderId = $orderTable->add(array('user' => $userId, 'detailsname' => 'tariff', 'detailsid' => $tariffId, 'startdate' => $currentDate->format($mysqlTimeDateFormat), 'enddate' => $endDate->format($mysqlTimeDateFormat)));
$moneyFlowTable->add(array('user' => $userId, 'detailsname' => 'order', 'detailsid' => $orderId, 'sum' => money($sum)));
} else {
controllerRouterQueue($row['router'], "update", $row['id']);
}
} else {
if ($mode == 1) {
if ($row['disabled'] == '0' && ($newCash < $minimumCash && $row['credit'] == '0')) {
controllerRouterQueue($row['router'], "shownotification", $row['id']);
}
}
}
}
} else {
$routerTable = new table('router');
$routerRes = $routerTable->load($id ? "WHERE id={$id}" : "");
foreach ($routerRes as $row) {
controllerRouterQueue($row['id'], 'clearnotification', $id);
}
}
}
示例3: foreach
foreach ($data as $key => $value) {
if ($key !== 'id' && !checkPermission($sessionId, array('table', $target, 'edit', $key))) {
unset($data[$key]);
}
}
}
// Extract cash difference from user and proceed as moneflow
if ($target == 'user' && ($action == 'dbedit' || $action == 'dbadd') && isset($data['cash'])) {
unset($data['cash']);
}
switch ($action) {
case 'dbadd':
$id = $table->add($data);
break;
case 'dbedit':
$id = $table->edit($data);
break;
case 'dbremove':
$id = $table->delete($data);
break;
}
if ($target == 'user' && ($action == 'dbedit' || $action == 'dbadd') && isset($_POST['cash']) && checkPermission($sessionId, array('table', $target, 'edit', 'cash'))) {
if ($action === 'dbedit') {
$user = $table->loadById($id);
$sum = money($_POST['cash']) - money($user['cash']);
} else {
$sum = money($_POST['cash']);
}
if ($sum) {
$moneyflowTable = new table('moneyflow');
$moneyflowTable->add(array("user" => $id, "sum" => $sum, "detailsname" => "adminpay", "detailsid" => $sessionId));