本文整理汇总了PHP中add函数的典型用法代码示例。如果您正苦于以下问题:PHP add函数的具体用法?PHP add怎么用?PHP add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addLocation
function addLocation()
{
$request = Slim::getInstance()->request();
$body = json_decode($request->getBody());
//print_r($body);exit;
if (isset($body->id)) {
unset($body->id);
}
$unique_field = array();
$unique_field['city'] = $body->city;
$unique_field['country_id'] = $body->country_id;
$rowcount = rowCountByCondition($unique_field, 'locations');
//echo $rowcount;exit;
if ($rowcount == 0) {
$allinfo['save_data'] = $body;
//$allinfo['unique_data'] = $unique_field;
$location_details = add(json_encode($allinfo), 'locations');
//var_dump($location_details);
//exit;
if (!empty($location_details)) {
/* $user_details = add(json_encode($allinfo),'coupons');
$user_details = json_decode($user_details);*/
$result = '{"type":"success","message":"Added Succesfully"}';
} else {
$result = '{"type":"error","message":"Not Added"}';
}
} else {
$result = '{"type":"error","message":"Already exists"}';
}
echo $result;
}
示例2: add
function add($productId, $qty = 1)
{
if (is_array($productId)) {
foreach ($productId as $pid => $qty) {
add($pid, $qty);
}
return getList();
}
$user = \cf\User::getLoggedIn();
if ($user) {
$cartId = create();
$oldQty = \cf\query2var('SELECT amount FROM cf_products_in_cart WHERE cart_id=:cid AND product_id=:pid AND status=0', array('cid' => $cartId, 'pid' => $productId));
if ($oldQty) {
\cf\execQuery('UPDATE cf_products_in_cart SET amount=:amt WHERE cart_id=:cid AND product_id=:pid', array('cid' => $cartId, 'pid' => $productId, 'amt' => $qty + $oldQty));
} else {
\cf\execQuery('INSERT INTO cf_products_in_cart (cart_id,product_id,amount) VALUES(:cid,:pid,:amt)', array('cid' => $cartId, 'pid' => $productId, 'amt' => $qty));
}
} else {
$c = create();
$products = $c->getParam('ready');
if (array_key_exists($productId, $products)) {
$products[$productId] += (int) $qty;
} else {
$products[$productId] = (int) $qty;
}
$c->setParam('ready', $products);
$c->set();
}
return getList();
}
示例3: getIt
function getIt()
{
if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
$number = getLastId();
$sitrng = "poczekalnia/z" . "{$number}" . ".png";
// Get the data
$imageData = $GLOBALS['HTTP_RAW_POST_DATA'];
// Remove the headers (data:,) part.
// A real application should use them according to needs such as to check image type
$filteredData = substr($imageData, strpos($imageData, ",") + 1);
// Need to decode before saving since the data we received is already base64 encoded
$unencodedData = base64_decode($filteredData);
//echo "unencodedData".$unencodedData;
// Save file. This example uses a hard coded filename for testing,
// but a real application can specify filename in POST variable
$fp = fopen($sitrng, 'wb');
fwrite($fp, $unencodedData);
fclose($fp);
add($sitrng, $_COOKIE['words'], $_COOKIE['author'], $_COOKIE['nick'], $_COOKIE['book'], $_COOKIE['tag']);
setcookie("words", "", time());
$files = glob('upload/*');
// get all file names
foreach ($files as $file) {
// iterate files
if (is_file($file)) {
unlink($file);
}
// delete file
}
}
}
示例4: remove
function remove($_POST)
{
# processes
db_connect();
# Get vars
extract($_POST);
$id += 0;
if (isset($back)) {
return add($_POST);
}
# validate input
require_lib("validate");
$v = new validate();
# display errors, if any
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class='err'>" . $e["msg"] . "</li>";
}
$confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirm;
}
db_conn('cubit');
$sql = "DELETE FROM batch_cashbook WHERE cashid='{$id}'";
$accntRslt = db_exec($sql) or errDie("ERROR: Unable to retrieve bank deposits details from database.", SELF);
# Status report
$write = "\n\t\t\t\t\t<table " . TMPL_tblDflts . " width='100%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Batch Cashbook entry deleted</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class='datacell'>\n\t\t\t\t\t\t\t<td>Batch Cashbook entry has been deleted</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>";
# Main table (layout with menu)
$OUTPUT = "\n\t\t\t\t<center>\n\t\t\t\t<table width = 90%>\n\t\t\t\t\t<tr valign='top'>\n\t\t\t\t\t\t<td width='50%'>{$write}</td>\n\t\t\t\t\t\t<td align='center'>\n\t\t\t\t\t\t<table " . TMPL_tblDflts . " width='80%'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Quick Links</th>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td><a href='bank-pay-add.php'>Add Bank Payment</a></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td><a href='bank-recpt-add.php'>Add Bank Receipt</a></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td><a href='cashbook-view.php'>View Cash Book</a></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>";
return $OUTPUT;
}
示例5: show_error
function show_error($msg)
{
global $w;
add('', $msg, 'Fehler');
echo $w->toxml();
exit;
}
示例6: getRecordWhere
public function getRecordWhere($data)
{
$result = null;
$adapter = GlobalAdapterFeature::getStaticAdapter();
$connection = $adapter->getDriver()->getConnection($data);
$connection->beginTransaction();
try {
function add($datas)
{
global $data;
$data = $datas;
}
add($data);
function set(Select $select)
{
global $data;
foreach ($data as $key => $value) {
$select->where->like($key, "%{$value}%");
}
}
$result = $this->area->select(function (Select $select) {
set($select);
});
$connection->commit();
} catch (\Exception $e) {
$connection->rollback();
}
return $result;
}
示例7: addCat
function addCat()
{
$request = Slim::getInstance()->request();
$body = json_decode($request->getBody());
//print_r($body);exit;
if (isset($body->id)) {
unset($body->id);
}
$unique_field = array();
$unique_field['name'] = $body->name;
$rowcount = rowCount(json_encode($unique_field), 'category');
//echo $rowcount;exit;
if ($rowcount == 0) {
$allinfo['save_data'] = $body;
if (!empty($body->icon)) {
$body->icon->filename = time() . $body->icon->filename;
file_put_contents('category_icons/' . $body->icon->filename, base64_decode($body->icon->base64));
$body->icon = $body->icon->filename;
}
//$allinfo['unique_data'] = $unique_field;
$cat_details = add(json_encode($allinfo), 'category');
if (!empty($cat_details)) {
/* $user_details = add(json_encode($allinfo),'coupons');
$user_details = json_decode($user_details);*/
$result = '{"type":"success","message":"Added Succesfully"}';
} else {
$result = '{"type":"error","message":"Not Added"}';
}
} else {
$result = '{"type":"error","message":"Already exists"}';
}
echo $result;
}
示例8: write
function write()
{
extract($_POST);
if (isset($back)) {
return add($_POST);
}
require_lib("validate");
$v = new validate();
$v->isOk($bankid, "num", 1, 30, "Invalid Bank Account.");
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class=err>" . $e["msg"];
}
$confirm .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirm;
}
$bank = qryBankAcct($bankid);
$cols = grp(m("type", "Banking Details Account"), m("label", "BANK_DET"), m("value", $bankid), m("descript", "Bank Account: ({$bank['acctype']}) {$bank['accname']} - {$bank['bankname']}"), m("div", USER_DIV));
$qry = new dbUpdate("set", "cubit", $cols, "label = 'BANK_DET' AND div = '" . USER_DIV . "'");
$qry->run(DB_REPLACE);
$write = "\n\t<table " . TMPL_tblDflts . ">\n\t<tr>\n\t\t<th>Bank Details Account</th>\n\t</tr>\n\t<tr class='text'>\n\t\t<td>Bank Details Account have been set to Bank Account: ({$bank['acctype']}) {$bank['accname']} - {$bank['bankname']}.</td>\n\t</tr>\n\t</table>" . mkQuickLinks();
return $write;
}
示例9: printS
function printS($id)
{
$ci =& get_instance();
$s = new Section();
$s->get_by_id($id);
$s->e = anchor($ci->app->app_url('edit/') . $s->id, 'Edit');
$s->d = anchor($ci->app->app_url('delete/') . $s->id, 'Delete');
$output = "<li>";
$output .= $s->id . '|';
$output .= $s->name;
$output .= add($id, 0, "add first child for {$s->name}");
$output .= '|';
$output .= $s->e;
$output .= '|';
$output .= $s->d;
$c = new Section();
$c->where('parent_section', $id);
$c->order_by('sort', 'asc');
$c->get();
if (count($c->all) > 0) {
$output .= "<ul>";
foreach ($c->all as $item) {
$output .= printS($item->id);
$output .= "<li>" . add($id, $item->sort + 1) . "</li>";
}
$output .= "</ul>";
}
$output .= "</li>";
return $output;
}
示例10: transform
function transform($a, $tx, $ty)
{
$x = trim($a[0]);
$y = trim($a[1]);
$x = add($x, $tx);
$y = add($y, $ty);
return $x . "," . $y;
}
示例11: main
function main()
{
$a = new Foo();
$a->identity(232);
$a->identity(42);
$a->identity(0);
add(1, 1);
add(0, 0);
}
示例12: add
function add($i)
{
if ($i < 1) {
return $i;
} else {
run();
return $i + add($i - 1);
}
}
示例13: signup
public function signup()
{
if (isset($_POST['form_action'])) {
$input = array('email' => $_POST['email'], 'password' => $_POST['password']);
print_r($input);
add('User', $input);
}
$vars['user'] = new User();
$this->l('Template')->load('user/signup', 'base', $vars)->output();
}
示例14: add
function add($array, $n, $len, $cnt)
{
if ($cnt == 0) {
return array_splice($array, $len - $cnt, 0, $n);
}
if ($n < $array[$len - $cnt]) {
array_splice($array, $len - $cnt, 0, $n);
return $array;
}
return add($array, $n, $len, $cnt - 1);
}
示例15: __construct
public function __construct($patNum)
{
//check if patient table already exists
$database = new Database();
$database->query('SELECT TableNum, Discharged FROM patients WHERE HosNum = :num');
$database->bind(':num', $patNum);
$row = $database->single();
if ($row) {
} else {
add();
}
}