本文整理汇总了PHP中Collection::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::delete方法的具体用法?PHP Collection::delete怎么用?PHP Collection::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection::delete方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeNode
/**
* Enter description here...
*
* @param Node $node
* @return Varien_Data_Tree
*/
public function removeNode($node)
{
$this->_nodes->delete($node);
if ($node->getParent()) {
$node->getParent()->removeChild($node);
}
unset($node);
return $this;
}
示例2: testDeleteAlsoDeletesAssociatedItems
function testDeleteAlsoDeletesAssociatedItems()
{
// Arrange
$collection_name = "Star Wars Cards";
$test_collection = new Collection($collection_name);
$test_collection->save();
$collection_id = $test_collection->getId();
$item_name = "Boba Fett";
$test_item = new Item($item_name, $collection_id);
$test_item->save();
$item_name2 = "Slave 1";
$test_item2 = new Item($item_name2, $collection_id);
$test_item2->save();
// Act
$test_collection->delete();
// Assert
$this->assertEquals([], Item::getAll());
}
示例3: xmldb_core_upgrade
//.........这里部分代码省略.........
if ($oldversion < 2009070700) {
foreach (array('addfriend', 'removefriend', 'addfriendrequest', 'removefriendrequest') as $eventtype) {
$event = (object) array('name' => $eventtype);
ensure_record_exists('event_type', $event, $event);
}
}
if ($oldversion < 2009070900) {
if (is_mysql()) {
execute_sql("ALTER TABLE {usr} DROP FOREIGN KEY {usr_las_fk}");
execute_sql("ALTER TABLE {usr} DROP INDEX {usr_las_ix}");
}
$table = new XMLDBTable('usr');
$field = new XMLDBField('lastauthinstance');
drop_field($table, $field);
}
if ($oldversion < 2009080600) {
$table = new XMLDBTable('view');
$index = new XMLDBIndex('view_own_type_uix');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('owner'));
if (!index_exists($table, $index)) {
// Delete duplicate profile views if there are any, then add an index
// that will prevent it happening again - but only on postgres, as it's
// the only db that supports partial indexes
if ($viewdata = get_records_sql_array("\n SELECT owner, id\n FROM {view}\n WHERE owner IN (\n SELECT owner\n FROM {view}\n WHERE type = 'profile'\n GROUP BY owner\n HAVING COUNT(*) > 1\n )\n AND type = 'profile'\n ORDER BY owner, id", array())) {
require_once 'view.php';
$seen = array();
foreach ($viewdata as $record) {
$seen[$record->owner][] = $record->id;
}
foreach ($seen as $owner => $views) {
// Remove the first one, which is their real profile view
array_shift($views);
foreach ($views as $viewid) {
delete_records('artefact_feedback', 'view', $viewid);
delete_records('view_feedback', 'view', $viewid);
delete_records('view_access', 'view', $viewid);
delete_records('view_access_group', 'view', $viewid);
delete_records('view_access_usr', 'view', $viewid);
delete_records('view_access_token', 'view', $viewid);
delete_records('view_autocreate_grouptype', 'view', $viewid);
delete_records('view_tag', 'view', $viewid);
delete_records('usr_watchlist_view', 'view', $viewid);
if ($blockinstanceids = get_column('block_instance', 'id', 'view', $viewid)) {
foreach ($blockinstanceids as $id) {
if (table_exists(new XMLDBTable('blocktype_wall_post'))) {
delete_records('blocktype_wall_post', 'instance', $id);
}
delete_records('view_artefact', 'block', $id);
delete_records('block_instance', 'id', $id);
}
}
delete_records('view', 'id', $viewid);
}
}
}
if (is_postgres()) {
execute_sql("CREATE UNIQUE INDEX {view_own_type_uix} ON {view}(owner) WHERE type = 'profile'");
}
}
}
if ($oldversion < 2009080601) {
execute_sql("DELETE FROM {group_member_invite} WHERE \"group\" NOT IN (SELECT id FROM {group} WHERE jointype = 'invite')");
execute_sql("DELETE FROM {group_member_request} WHERE \"group\" NOT IN (SELECT id FROM {group} WHERE jointype = 'request')");
}
if ($oldversion < 2009081800) {
$event = (object) array('name' => 'creategroup');
示例4: delete
function delete()
{
Loader::model('page_statistics');
$cID = $this->getCollectionID();
if ($cID <= 1) {
return false;
}
$db = Loader::db();
// run any internal event we have for page deletion
$ret = Events::fire('on_page_delete', $this);
if ($ret < 0) {
return false;
}
parent::refreshCache();
parent::delete();
$cID = $this->getCollectionID();
$cParentID = $this->getCollectionParentID();
// Now that all versions are gone, we can delete the collection information
$q = "delete from PagePaths where cID = '{$cID}'";
$r = $db->query($q);
// remove all pages where the pointer is this cID
$r = $db->query("select cID from Pages where cPointerID = ?", array($cID));
while ($row = $r->fetchRow()) {
PageStatistics::decrementParents($row['cID']);
}
// Update cChildren for cParentID
PageStatistics::decrementParents($cID);
$q = "delete from PagePermissionAssignments where cID = '{$cID}'";
$r = $db->query($q);
$q = "delete from Pages where cID = '{$cID}'";
$r = $db->query($q);
$q = "delete from Pages where cPointerID = '{$cID}'";
$r = $db->query($q);
$q = "delete from Areas WHERE cID = '{$cID}'";
$r = $db->query($q);
$q = "delete from ComposerDrafts WHERE cID = '{$cID}'";
$r = $db->query($q);
$db->query('delete from PageSearchIndex where cID = ?', array($cID));
$q = "select cID from Pages where cParentID = '{$cID}'";
$r = $db->query($q);
if ($r) {
while ($row = $r->fetchRow()) {
if ($row['cID'] > 0) {
$nc = Page::getByID($row['cID']);
if ($nc->isAlias()) {
$nc->removeThisAlias();
} else {
$nc->delete();
}
}
}
}
}
示例5: delete
function delete()
{
Loader::model('page_statistics');
$cID = $this->getCollectionID();
if ($cID <= 1) {
return false;
}
$db = Loader::db();
// run any internal event we have for page deletion
$ret = Events::fire('on_page_delete', $this);
if ($ret < 0) {
return false;
}
Log::addEntry(t('Page "%s" at path "%s" deleted', $this->getCollectionName(), $this->getCollectionPath()), t('Page Action'));
if ($this->isAlias() && $this->getCollectionPointerExternalLink() == '') {
$this->removeThisAlias();
} else {
parent::delete();
$cID = $this->getCollectionID();
$cParentID = $this->getCollectionParentID();
// Now that all versions are gone, we can delete the collection information
$q = "delete from PagePaths where cID = '{$cID}'";
$r = $db->query($q);
// remove all pages where the pointer is this cID
$r = $db->query("select cID from Pages where cPointerID = ?", array($cID));
while ($row = $r->fetchRow()) {
PageStatistics::decrementParents($row['cID']);
$db->Execute('DELETE FROM PagePaths WHERE cID=?', array($row['cID']));
}
// Update cChildren for cParentID
PageStatistics::decrementParents($cID);
$q = "delete from PagePermissionAssignments where cID = '{$cID}'";
$r = $db->query($q);
$q = "delete from Pages where cID = '{$cID}'";
$r = $db->query($q);
$q = "delete from Pages where cPointerID = '{$cID}'";
$r = $db->query($q);
$q = "delete from Areas WHERE cID = '{$cID}'";
$r = $db->query($q);
$q = "delete from ComposerDrafts WHERE cID = '{$cID}'";
$r = $db->query($q);
$db->query('delete from PageSearchIndex where cID = ?', array($cID));
$q = "select cID from Pages where cParentID = '{$cID}'";
$r = $db->query($q);
if ($r) {
while ($row = $r->fetchRow()) {
if ($row['cID'] > 0) {
$nc = Page::getByID($row['cID']);
if ($nc->isAlias()) {
$nc->removeThisAlias();
} else {
$nc->delete();
}
}
}
}
}
$cache = PageCache::getLibrary();
$cache->purge($this);
}
示例6: testDeleteCollection_ExceptionOnCollectionDeleteError
/**
* @expectedException \Sokil\Mongo\Exception
* @expectedExceptionMessage Error deleting collection phpmongo_test_collection: Some strange error
*/
public function testDeleteCollection_ExceptionOnCollectionDeleteError()
{
$this->collectionMock = $this->getMock('\\MongoCollection', array('drop'), array($this->database->getMongoDB(), 'phpmongo_test_collection'));
$this->collectionMock->expects($this->once())->method('drop')->will($this->returnValue(array('ok' => (double) 0, 'errmsg' => 'Some strange error')));
$collection = new Collection($this->database, $this->collectionMock);
$collection->delete();
}
示例7: tearDown
public function tearDown()
{
$this->collection->delete();
}
示例8: delete_user
/**
* Deletes a user
*
* This function ensures that a user is deleted according to how Mahara wants a
* deleted user to be. You can call it multiple times on the same user without
* harm.
*
* @param int $userid The ID of the user to delete
*/
function delete_user($userid)
{
db_begin();
// We want to append 'deleted.timestamp' to some unique fields in the usr
// table, so they can be reused by new accounts
$fieldstomunge = array('username', 'email');
$datasuffix = '.deleted.' . microtime(true);
$user = get_record('usr', 'id', $userid, null, null, null, null, implode(', ', $fieldstomunge));
$deleterec = new StdClass();
$deleterec->id = $userid;
$deleterec->deleted = 1;
foreach ($fieldstomunge as $field) {
if (!preg_match('/\\.deleted\\.\\d+$/', $user->{$field})) {
$deleterec->{$field} = $user->{$field} . $datasuffix;
}
}
// Set authinstance to default internal, otherwise the old authinstance can be blocked from deletion
// by deleted users.
$authinst = get_field('auth_instance', 'id', 'institution', 'mahara', 'authname', 'internal');
if ($authinst) {
$deleterec->authinstance = $authinst;
}
// Free the urlid for another user to use
$deleterec->urlid = null;
update_record('usr', $deleterec);
// Remove user from any groups they're in, invited to or want to be in
$groupids = get_column('group_member', '"group"', 'member', $userid);
if ($groupids) {
require_once get_config('libroot') . 'group.php';
foreach ($groupids as $groupid) {
group_remove_user($groupid, $userid, true);
}
}
delete_records('group_member_request', 'member', $userid);
delete_records('group_member_invite', 'member', $userid);
// Remove any friend relationships the user is in
execute_sql('DELETE FROM {usr_friend}
WHERE usr1 = ?
OR usr2 = ?', array($userid, $userid));
execute_sql('DELETE FROM {usr_friend_request}
WHERE owner = ?
OR requester = ?', array($userid, $userid));
// Delete the user from others' favourites lists
delete_records('favorite_usr', 'usr', $userid);
// Delete favourites lists owned by the user
execute_sql('DELETE FROM {favorite_usr} WHERE favorite IN (SELECT id FROM {favorite} WHERE owner = ?)', array($userid));
delete_records('favorite', 'owner', $userid);
delete_records('artefact_access_usr', 'usr', $userid);
delete_records('auth_remote_user', 'localusr', $userid);
delete_records('import_queue', 'usr', $userid);
delete_records('usr_account_preference', 'usr', $userid);
delete_records('usr_activity_preference', 'usr', $userid);
delete_records('usr_infectedupload', 'usr', $userid);
delete_records('usr_institution', 'usr', $userid);
delete_records('usr_institution_request', 'usr', $userid);
delete_records('usr_password_request', 'usr', $userid);
delete_records('usr_watchlist_view', 'usr', $userid);
delete_records('view_access', 'usr', $userid);
delete_records('usr_login_data', 'usr', $userid);
// Remove the user's views & artefacts
$viewids = get_column('view', 'id', 'owner', $userid);
if ($viewids) {
require_once get_config('libroot') . 'view.php';
foreach ($viewids as $viewid) {
$view = new View($viewid);
$view->delete();
}
}
$artefactids = get_column('artefact', 'id', 'owner', $userid);
// @todo: test all artefact bulk_delete stuff, then replace the one-by-one
// artefact deletion below with ArtefactType::delete_by_artefacttype($artefactids);
if ($artefactids) {
foreach ($artefactids as $artefactid) {
try {
$a = artefact_instance_from_id($artefactid, true);
if ($a) {
$a->delete();
}
} catch (ArtefactNotFoundException $e) {
// Awesome, it's already gone.
}
}
}
// Remove the user's collections
$collectionids = get_column('collection', 'id', 'owner', $userid);
if ($collectionids) {
require_once get_config('libroot') . 'collection.php';
foreach ($collectionids as $collectionid) {
$collection = new Collection($collectionid);
$collection->delete();
}
//.........这里部分代码省略.........
示例9: foreach
function delete_submit(Pieform $form, $values)
{
global $SESSION;
$authinstanceids = get_column('auth_instance', 'id', 'institution', $values['i']);
$collectionids = get_column('collection', 'id', 'institution', $values['i']);
$viewids = get_column('view', 'id', 'institution', $values['i']);
$artefactids = get_column('artefact', 'id', 'institution', $values['i']);
$regdataids = get_column('institution_registration', 'id', 'institution', $values['i']);
db_begin();
if ($collectionids) {
require_once get_config('libroot') . 'collection.php';
foreach ($collectionids as $collectionid) {
$collection = new Collection($collectionid);
$collection->delete();
}
}
if ($viewids) {
require_once get_config('libroot') . 'view.php';
foreach ($viewids as $viewid) {
$view = new View($viewid);
$view->delete();
}
}
if ($artefactids) {
foreach ($artefactids as $artefactid) {
try {
$a = artefact_instance_from_id($artefactid);
$a->delete();
} catch (ArtefactNotFoundException $e) {
// Awesome, it's already gone.
}
}
}
// If any users are still using this institution's authinstances, change them now.
if ($authinstanceids) {
execute_sql("\n UPDATE {usr}\n SET authinstance = (\n SELECT MIN(id) FROM {auth_instance} WHERE institution = 'mahara' AND authname = 'internal'\n )\n WHERE authinstance IN (" . join(',', array_fill(0, count($authinstanceids), '?')) . ')', $authinstanceids);
}
foreach ($authinstanceids as $id) {
delete_records('auth_instance_config', 'instance', $id);
}
foreach ($regdataids as $id) {
delete_records('institution_registration_data', 'registration_id', $id);
}
// The institution should have been removed from favourites lists when the members were removed,
// but make sure it's gone.
execute_sql('DELETE FROM {favorite_usr} WHERE favorite IN (SELECT id FROM {favorite} WHERE institution = ?)', array($values['i']));
delete_records('favorite', 'institution', $values['i']);
execute_sql("UPDATE {group} SET institution = NULL, shortname = NULL WHERE institution = ?", array($values['i']));
delete_records('auth_instance', 'institution', $values['i']);
delete_records('host', 'institution', $values['i']);
delete_records('institution_locked_profile_field', 'name', $values['i']);
delete_records('usr_institution_request', 'institution', $values['i']);
delete_records('view_access', 'institution', $values['i']);
delete_records('institution_data', 'institution', $values['i']);
delete_records('institution_registration', 'institution', $values['i']);
delete_records('site_content', 'institution', $values['i']);
delete_records('institution_config', 'institution', $values['i']);
delete_records('usr_custom_layout', 'institution', $values['i']);
delete_records('usr_registration', 'institution', $values['i']);
delete_records('institution', 'name', $values['i']);
db_commit();
$SESSION->add_ok_msg(get_string('institutiondeletedsuccessfully', 'admin'));
redirect('/admin/users/institutions.php');
}
示例10: getOldOnce
/**
* @param string $name
* @param string $def
* @return string
*/
public function getOldOnce($name, $def = '')
{
if ($this->storage) {
$old_once = $this->storage->get(OldValue::OLD_ONCE_KEY);
$old_once = new Collection($old_once);
if ($old_once->has($name)) {
$v = $old_once->get($name);
$old_once->delete($name);
$this->storage->set(OldValue::OLD_ONCE_KEY, $old_once->get());
return $v;
}
}
return $def;
}
示例11: test7_Deletion
public function test7_Deletion()
{
# deletion
static::$collection->delete('part2.item2', 'name');
$this->assertTrue(!static::$collection->has('part2.item2.name'));
}
示例12: testShouldDeleteRecordsAccordingToCriteria
public function testShouldDeleteRecordsAccordingToCriteria()
{
$collection = new Collection(new Factory());
$collection->insert(array('name' => 'A'));
$collection->insert(array('name' => 'B'));
$collection->insert(array('name' => 'C'));
$criteria = array('name' => 'B');
$collection->delete($criteria);
$this->assertCount(2, $collection);
}
示例13: catch
Flight::ok($object);
} catch (Exception $exception) {
Flight::error($exception);
}
});
Flight::route('PUT /v1/main/collection/@id', function ($id) {
try {
$object = Collection::update($id);
Flight::ok($object);
} catch (Exception $exception) {
Flight::error($exception);
}
});
Flight::route('DELETE /v1/main/collection/@id', function ($id) {
try {
$object = Collection::delete($id);
Flight::ok($object);
} catch (Exception $exception) {
Flight::error($exception);
}
});
//=============================================================================
//Company
//=============================================================================
Flight::route('GET /v1/main/company', function () {
try {
$array = Company::selectAll();
Flight::ok($array);
} catch (Exception $exception) {
Flight::error($exception);
}
示例14: removeChild
public function removeChild($childNode)
{
$this->_childNodes->delete($childNode);
return $this;
}