本文整理汇总了PHP中Collection::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::save方法的具体用法?PHP Collection::save怎么用?PHP Collection::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save($relationshipName = NULL)
{
if (!empty($relationshipName)) {
throw new PolymorphicException('Relationship path "' . $relationshipName . '" has no meaning for polymorphic collections');
}
return parent::save();
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$collection = new Collection();
$collection->name = Input::get('name');
$collection->save();
return Redirect::route('collection.index');
}
示例3: hookInstall
public function hookInstall()
{
//set up my Collectors table
$db = get_db();
$sql = "\n CREATE TABLE IF NOT EXISTS `{$db->Collector}` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `collection_id` int(10) unsigned NOT NULL,\n `name` TEXT NOT NULL,\n `bio` TEXT NOT NULL,\n `public` tinyint(1) default '0',\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$db->query($sql);
//set up some fake data to work with
//this is the kind of work that is usually done in a Controller when processing a form
$collection = new Collection();
$collection->name = "Fake Collection";
$collection->owner_id = 1;
$collection->save();
$collector = new Collector();
$collector->name = "Mr. Fake Collector";
$collector->collection_id = $collection->id;
$collector->bio = "I collected stuff for the Fake Collection";
$collector->public = 1;
$collector->save();
$collector = new Collector();
$collector->name = "Mysterious Ghost Collector";
$collector->collection_id = $collection->id;
$collector->bio = "I collected stuff for the Fake Collection, but in secret so I don't want the public to know";
$collector->public = 0;
$collector->save();
$collection = new Collection();
$collection->name = "Pseudo Collection";
$collection->owner_id = 1;
$collection->save();
$collector = new Collector();
$collector->name = "Mrs. Pseudo Collector";
$collector->collection_id = $collection->id;
$collector->bio = "I collected stuff for the Pseudo Collection";
$collector->public = 1;
$collector->save();
}
示例4: testMapWithoutCollection
public function testMapWithoutCollection()
{
$collection = new Collection();
$collection->addElementTextsByArray(array('Dublin Core' => array('Title' => array(array('text' => 'Plants', 'html' => false)))));
$collection->save();
$row = array('title' => 'Animals', 'description' => 'Foo');
$map = new CsvImport_ColumnMap_Collection('title');
$this->assertFalse($map->map($row, array()));
}
示例5: submit
function submit(Pieform $form, $values)
{
global $SESSION, $new;
$collection = Collection::save($values);
if (!$new) {
$SESSION->add_ok_msg(get_string('collectionsaved', 'collection'));
}
$collection->post_edit_redirect($new);
}
示例6: testMapWithoutCollection
public function testMapWithoutCollection()
{
$collection = new Collection();
$collection->addElementTextsByArray(array('Dublin Core' => array('Title' => array(array('text' => 'Plants', 'html' => false)))));
$collection->save();
$row = array('title' => 'Animals', 'description' => 'Foo');
$map = new CsvImport_ColumnMap_Collection('title');
$this->markTestSkipped(__('Since 2.2-full, collections are checked during import.'));
$this->assertFalse($map->map($row, array()));
}
示例7: Collection
function test_find()
{
//Arrange
$name = "Hello Kitty";
$name2 = "Pokemon";
$test_collection = new Collection($name);
$test_collection->save();
$test_collection2 = new Collection($name2);
$test_collection2->save();
//Act
$result = Collection::find($test_collection2->getId());
//Assert
$this->assertEquals($test_collection2, $result);
}
示例8: setUp
public function setUp()
{
parent::setUp();
// Set the ACL to allow access to collections
$this->acl = $this->application->getBootstrap()->acl;
$this->acl->allow(null, 'Collections');
$this->db = $this->application->getBootstrap()->db;
$this->user = $this->db->getTable('User')->find(1);
$this->_authenticateUser($this->user);
// Create a collection
$collection = new Collection();
$collection->public = true;
$collection->save();
$this->collection = $collection;
}
示例9: Collection
function test_find()
{
//Arrange
$thing = "Run the World";
$thing2 = "20 20 Experience";
$test_collection = new Collection($thing);
$test_collection->save();
$test_collection2 = new Collection($thing2);
$test_collection2->save();
//Act
$id = $test_collection->getId();
$result = Collection::find($id);
//Assert
$this->assertEquals($test_collection, $result);
}
示例10: testOwnerIdNotSetWhenUpdatingCollection
public function testOwnerIdNotSetWhenUpdatingCollection()
{
$user = $this->_getDefaultUser();
$this->_authenticateUser($user);
//create collection
$collection = new Collection();
$elementTexts = array('Dublin Core' => array('Title' => array(array('text' => 'foobar', 'html' => false)), 'Description' => array(array('text' => 'baz', 'html' => false))));
$collection->addElementTextsByArray($elementTexts);
$collection->owner_id = $user->id + 1;
$collection->save();
$csrf = new Omeka_Form_Element_SessionCsrfToken('csrf_token');
$this->request->setPost(array('Elements' => array(), 'csrf_token' => $csrf->getToken()));
$this->request->setMethod('post');
$this->dispatch('collections/edit/' . $collection->id);
$this->assertRedirect();
$updatedCollection = $this->db->getTable('Collection')->find($collection->id);
$this->assertNotEquals($user->id, $updatedCollection->owner_id, "The owner_id for the collection should not be that of the user who updated the collection.");
}
示例11: doSave
/**
* Performs the work of inserting or updating the row in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave(PropelPDO $con)
{
$affectedRows = 0;
// initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aCollection !== null) {
if ($this->aCollection->isModified() || $this->aCollection->isNew()) {
$affectedRows += $this->aCollection->save($con);
}
$this->setCollection($this->aCollection);
}
if ($this->aFile !== null) {
if ($this->aFile->isModified() || $this->aFile->isNew()) {
$affectedRows += $this->aFile->save($con);
}
$this->setFile($this->aFile);
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = CollectionFilePeer::doInsert($this, $con);
$affectedRows += 1;
// we are assuming that there is only 1 row per doInsert() which
// should always be true here (even though technically
// BasePeer::doInsert() can insert multiple rows).
$this->setNew(false);
} else {
$affectedRows += CollectionFilePeer::doUpdate($this, $con);
}
$this->resetModified();
// [HL] After being saved an object is no longer 'modified'
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例12: submit
function submit(Pieform $form, $values)
{
global $SESSION, $new, $copy, $urlparams;
$values['navigation'] = (int) $values['navigation'];
$collection = Collection::save($values);
if (!$new) {
$SESSION->add_ok_msg(get_string('collectionsaved', 'collection'));
}
$collection->post_edit_redirect($new, $copy, $urlparams);
}
示例13: MakeDuplicateCollection
/**
*Create a new Omeka collection from a Flickr collection
*
*@param string $setID A unique identifier for the Flickr collection
*from which to extract metadata
*@param string $type The type of Flickr collection
*@param object $f The phpFlickr interface
*@param int $collection The ID of the collection to which to add the new item
*@param string $ownerRole The name of the dublin core field to which to
*add the new omeka item or items
*@param boolean $public Indicates whether the new omeka item should be public
*@return int $id The collection ID of the newly created Omeka collection
*/
public static function MakeDuplicateCollection($setID, $type = 'unknown', $f, $ownerRole = 0, $public = 1)
{
if ($type == "photoset") {
$setInfo = $f->photosets_getInfo($setID);
} else {
if ($type == "gallery") {
$response = $f->galleries_getInfo($setID);
if ($response['stat'] == "ok") {
$setInfo = $response['gallery'];
} else {
throw new Exception("Failed to retrieve gallery info from Flickr.");
}
} else {
if ($type == "photostream") {
$response = $f->people_getInfo($setID);
$setInfo = array('title' => $response['realname'] . " Flickr photostream", 'description' => "<p>The Flickr photostream of " . $response['realname'] . ", who uses the Flickr username " . $response['username'] . "</p><p>" . $response['description'] . "<p>", 'username' => $response['username']);
}
}
}
$maps = array("Dublin Core" => array('Title' => array($setInfo['title']), 'Description' => array($setInfo['description'])));
if ($ownerRole > "0") {
$maps["Dublin Core"][$ownerRole] = array($setInfo['username']);
}
$Elements = array();
$db = get_db();
$elementTable = $db->getTable('Element');
foreach ($maps as $elementSet => $elements) {
foreach ($elements as $elementName => $elementTexts) {
$element = $elementTable->findByElementSetNameAndElementName($elementSet, $elementName);
$elementID = $element->id;
$Elements[$elementID] = array();
foreach ($elementTexts as $elementText) {
if ($elementText != strip_tags($elementText)) {
//element text has html tags
$text = $elementText;
$html = true;
} else {
//plain text or other non-html object
$text = $elementText;
$html = false;
}
$Elements[$elementID][] = array('text' => $text, 'html' => $html);
}
}
}
$postArray = array('Elements' => $Elements);
if ($public) {
$postArray['public'] = "1";
}
$record = new Collection();
$record->setPostData($postArray);
if ($record->save(false)) {
// Succeed silently, since we're in the background
} else {
error_log($record->getErrors());
}
return $record->id;
}
示例14: testFind
function testFind()
{
//Arrange
$collection_name = "Rad stuff";
$test_collection = new Collection($collection_name);
$test_collection->save();
$test_collection_id = $test_collection->getId();
$name = "Hello Kitty";
$name2 = "Pokemon";
$test_item = new Item($name, $test_collection_id);
$test_item->save();
$test_item2 = new Item($name2, $test_collection_id);
$test_item2->save();
//Act
$result = Item::find($test_item2->getId());
//Assert
$this->assertEquals($test_item2, $result);
}
示例15: Collection
function page_admin_collections_create()
{
if (isset($_POST['path'])) {
$success = true;
$collection = new Collection();
$collection->path = $_POST['path'];
if ($collection->validate_path()) {
if ($collection->save()) {
$this->flash_success('Collection added');
} else {
$this->flash_error('Unable to save collection to database.');
}
} else {
$this->smarty->assign('path', $_POST['path']);
$this->flash_error('Collection could not be added. Check path.');
}
}
$this->content = './tpl/admin/collections/create.tpl';
}