本文整理汇总了PHP中Factory::createItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::createItem方法的具体用法?PHP Factory::createItem怎么用?PHP Factory::createItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory::createItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateTypeOptions
function generateTypeOptions($type, $empty, $value = '')
{
$return = $empty == true ? '<option value=""></option>' : '';
$factoryItem = Factory::createItem($type);
$optArr = $factoryItem->generateTypeOptions($type);
foreach ($optArr as $opt) {
$selected = $opt[0] == $value ? ' selected' : '';
$return .= '<option value="' . $opt[0] . '"' . $selected . '>' . htmlspecialchars($opt[1], ENT_QUOTES | ENT_HTML5, 'UTF-8') . '</option>';
}
return $return;
}
示例2: addChange
Outputs:
*/
if ($_POST['action'] == 'deleteAttachment') {
$return = ['status' => 'fail'];
if (unlink('attachments/' . $_POST['subID'])) {
$sth = $dbh->prepare('SELECT type, id, name, extension FROM attachments
WHERE attachmentID = :attachmentID');
$sth->execute([':attachmentID' => $_POST['subID']]);
$row = $sth->fetch();
$sth = $dbh->prepare('DELETE FROM attachments
WHERE attachmentID = :attachmentID');
$sth->execute([':attachmentID' => $_POST['subID']]);
$return = ['status' => 'success'];
addChange($row['type'], $row['id'], $_SESSION['employeeID'], 'D', json_encode(['subType' => 'attachment', 'name' => $row['name'], 'extension' => $row['extension']]));
}
echo json_encode($return);
}
/*
Function: customAjax
Inputs:
Outputs:
*/
if ($_POST['action'] == 'customAjax') {
$data = $_POST;
unset($data['action']);
unset($data['type']);
unset($data['id']);
$factoryItem = Factory::createItem($_POST['type']);
$return = $factoryItem->customAjax($_POST['id'], $data);
echo json_encode($return);
}
示例3: while
}
//recurring expenseOthers
$sth = $dbh->prepare('SELECT expenseID, name, unitPrice, quantity, recurringID, dayOfMonth
FROM expenseOthers
WHERE recurringID IS NOT NULL AND startDate <= :today AND endDate >= :today');
$sth->execute([':today' => $today]);
while ($row = $sth->fetch()) {
$day = date('j', $today);
if ($day == $row['dayOfMonth']) {
$sth2 = $dbh->prepare('INSERT INTO expenseOthers (expenseID, name, date, unitPrice, quantity, parentRecurringID)
VALUES(:expenseID, :name, :date, :unitPrice, :quantity, :parentRecurringID)');
$sth2->execute([':expenseID' => $row['expenseID'], ':name' => $row['name'], ':date' => $today, ':unitPrice' => $row['unitPrice'], ':quantity' => $row['quantity'], ':parentRecurringID' => $row['recurringID']]);
$expenseItem->updateAmountDue($row['expenseID']);
}
}
$orderItem = Factory::createItem('order');
//recurring orders_products
$sth = $dbh->prepare('SELECT orderProductID, orderID, productID, unitPrice, quantity, recurringID, dayOfMonth
FROM orders_products
WHERE recurringID IS NOT NULL AND startDate <= :today AND endDate >= :today');
$sth->execute([':today' => $today]);
while ($row = $sth->fetch()) {
$day = date('j', $today);
if ($day == $row['dayOfMonth']) {
$sth2 = $dbh->prepare('INSERT INTO orders_products (orderID, productID, date, unitPrice, quantity, parentRecurringID)
VALUES(:orderID, :productID, :date, :unitPrice, :quantity, :parentRecurringID)');
$sth2->execute([':orderID' => $row['orderID'], ':productID' => $row['productID'], ':date' => $today, ':unitPrice' => $row['unitPrice'], ':quantity' => $row['quantity'], ':parentRecurringID' => $row['recurringID']]);
$id = $dbh->lastInsertId();
//check for discounts on the item
$sth2 = $dbh->prepare('SELECT discountID, discountType, discountAmount
FROM orders_discounts