本文整理汇总了PHP中Entry::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Entry::delete方法的具体用法?PHP Entry::delete怎么用?PHP Entry::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entry
的用法示例。
在下文中一共展示了Entry::delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteEntry
function deleteEntry($id)
{
if (is_null($id)) {
Functions::setResponse(400);
}
try {
$c = new Entry($id);
$c->delete();
return true;
} catch (RuntimeException $e) {
Functions::setResponse(404);
}
}
示例2: __actionEdit
public function __actionEdit()
{
$callback = Administration::instance()->getPageCallback();
$entry_id = (int) $callback['context']['entry_id'];
if (@array_key_exists('save', $_POST['action']) || @array_key_exists("done", $_POST['action'])) {
$entry = Entry::loadFromID($entry_id);
$post = General::getPostData();
$fields = array();
if (isset($post['fields']) and !empty($post['fields'])) {
$fields = $post['fields'];
}
$entry->setFieldDataFromFormArray($fields);
###
# Delegate: EntryPreEdit
# Description: Just prior to editing of an Entry.
Extension::notify('EntryPreEdit', '/publish/edit/', array('entry' => &$entry));
$this->errors->flush();
$status = Entry::save($entry, $this->errors);
if ($status == Entry::STATUS_OK) {
// Check if there is a field to prepopulate
if (isset($_REQUEST['prepopulate']) && strlen(trim($_REQUEST['prepopulate'])) > 0) {
$field_handle = key($_REQUEST['prepopulate']);
$value = stripslashes(rawurldecode($_REQUEST['prepopulate'][$field_handle]));
$prepopulate_filter = "?prepopulate[{$field_handle}]=" . rawurlencode($value);
} else {
$prepopulate_filter = null;
}
###
# Delegate: EntryPostEdit
# Description: Editing an entry. Entry object is provided.
Extension::notify('EntryPostEdit', '/publish/edit/', array('entry' => $entry));
## WOOT
redirect(sprintf('%s/symphony/publish/%s/edit/%d/:saved/%s', URL, $entry->section, $entry->id, $prepopulate_filter));
}
// Oh dear
$this->entry = $entry;
$this->alerts()->append(__('An error occurred while processing this form. <a href="#error">See below for details.</a> <a class="more">Show a list of errors.</a>'), AlertStack::ERROR);
return;
} elseif (@array_key_exists('delete', $_POST['action']) && is_numeric($entry_id)) {
$callback = Administration::instance()->getPageCallback();
###
# Delegate: Delete
# Description: Prior to deleting an entry. Entry ID is provided, as an
# array to remain compatible with other Delete delegate call
Extension::notify('Delete', '/publish/', array('entry_id' => $entry_id));
Entry::delete($entry_id);
redirect(ADMIN_URL . '/publish/' . $callback['context']['section_handle'] . '/');
}
}
示例3: __actionIndex
public function __actionIndex()
{
$checked = is_array($_POST['items']) ? array_keys($_POST['items']) : null;
if (is_array($checked) && !empty($checked)) {
switch ($_POST['with-selected']) {
case 'delete':
$this->__actionDelete($checked, ADMIN_URL . '/blueprints/sections/');
break;
case 'delete-entries':
$entries = Symphony::Database()->query(sprintf("SELECT `id` FROM `tbl_entries` WHERE `section` IN ('%s')", implode("', '", $checked)));
if ($entries->length() > 0) {
foreach ($entries as $e) {
Entry::delete($e->id);
}
}
break;
}
}
}
示例4: saveData
public function saveData(MessageStack $errors, Entry $entry, $data = null)
{
$key = key($data);
$fields = current($data);
if (is_numeric($key)) {
$joined = Entry::loadFromId($key);
$section_handle = $joined->section;
Entry::delete($key);
} else {
$section_handle = $key;
}
$joined = new Entry();
$joined->section = $section_handle;
// Find the current user ID or just any ID at all:
if (isset(Administration::instance()->User) && Administration::instance()->User instanceof User) {
$joined->user_id = Administration::instance()->User->id;
} else {
if (isset(Frontend::instance()->User) && Frontend::instance()->User instanceof User) {
$joined->user_id = Frontend::instance()->User->id;
} else {
$joined->user_id = (int) Symphony::Database()->query("SELECT `id` FROM `tbl_users` ORDER BY `id` ASC LIMIT 1")->current()->id;
}
}
// Set entry data:
foreach ($fields as $field_handle => $value) {
$joined->data()->{$field_handle} = $value;
}
//echo '<pre>'; var_dump($section_handle); exit;
$status = Entry::save($joined, $errors);
if ($status != Entry::STATUS_OK) {
return $status;
}
$row = (object) array('entry_id' => $entry->id, 'joined_id' => $joined->id);
try {
Symphony::Database()->insert(sprintf('tbl_data_%s_%s', $entry->section, $this->{'element-name'}), (array) $row, Database::UPDATE_ON_DUPLICATE);
return self::STATUS_OK;
} catch (DatabaseException $e) {
$errors->append(null, (object) array('message' => $e->getMessage(), 'code' => $e->getDatabaseErrorCode()));
} catch (Exception $e) {
$errors->append(null, (object) array('message' => $e->getMessage(), 'code' => $e->getCode()));
}
return self::STATUS_ERROR;
}
示例5: actionGenerate
public function actionGenerate()
{
$names = file(getcwd() . "/protected/tests/names.txt");
$streets = file(getcwd() . "/protected/tests/streets.txt");
$name_arr = array();
$street_arr = array();
foreach ($names as $line) {
$name = explode(" ", $line);
$name_arr[] = trim($name[0]);
}
foreach ($streets as $line) {
$street = explode(" ", $line);
if (count($street) == 3) {
$name1 = trim($street[0]);
$name2 = trim($street[1]);
$name3 = trim($street[2]);
$street_arr[] = $name1 . " " . $name2 . " " . $name3 . ", Toronto";
}
}
$limit = 1000000;
for ($i = 0; $i < $limit; $i++) {
set_time_limit(0);
// resetting the MySQL timeout
echo "Creating an invoice #{$i} <br/>";
$invoice = new Invoice();
$invoice->name = $name_arr[rand(0, count($name_arr) - 1)];
$invoice->address = rand(1, 5000) . " " . $street_arr[rand(0, count($street_arr) - 1)];
$y = 2012;
//rand(2006,2012);
if ($y < 2012) {
$m = rand(1, 12);
} else {
$m = rand(1, 11);
}
$m = 11;
$d = rand(1, 2);
$invoice->date = date($y . '-' . $m . '-' . $d);
$invoice->delivery_date = date($y . '-' . $m . '-' . $d);
$invoice->phone1 = "647" . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9);
$invoice->delivery_date = date($y . '-' . $m . '-' . $d);
$invoice->delivery_cost = rand(10, 50);
if ($invoice->save()) {
$number_of_items = rand(3, 9);
for ($j = 0; $j < $number_of_items; $j++) {
$entry = new Entry();
$entry->invoice = $invoice->id;
$entry->inventory = rand(3, 2709);
$inventory = Inventory::model()->findByPk($entry->inventory);
if ($inventory) {
$entry->item = $inventory->name . " #" . $inventory->model;
$entry->quantity = rand(1, $inventory->quantity);
$entry->price = round($inventory->in * 1.3);
$entry->amount = round($entry->price * 0.9 * $entry->quantity);
if ($entry->save()) {
echo "--Entry Created! <br/>";
$inventory->quantity = $inventory->quantity - $entry->quantity;
if ($inventory->save()) {
echo "---Inventory Updated! <br/>";
} else {
$entry->delete();
echo "***Inventory Error! Failed to update <br/>";
}
} else {
echo "***Entry Error! <br/>";
print_r($entry->getErrors());
echo "<br/>";
}
} else {
echo "*Inventory Error! (invalid randomed inventory id) <br/>";
}
}
if ($invoice->Amount > 0) {
echo "Invoice Created! id=>" . $invoice->id . "<br/>";
} else {
echo "Invoice has no entries! Deleting id=>" . $invoice->id . "<br/>";
$invoice->delete();
}
} else {
echo "Invoice Error! <br/>";
print_r($invoice->getError());
echo "<br/>";
}
echo "<hr/>";
}
}