本文整理汇总了PHP中Publication::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Publication::save方法的具体用法?PHP Publication::save怎么用?PHP Publication::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Publication
的用法示例。
在下文中一共展示了Publication::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Book();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Book'])) {
$authordetails = Author::model()->findByAttributes(array('author_name' => $_POST['Book']['author']));
$publication = Publication::model()->findByAttributes(array('name' => $_POST['Book']['publisher']));
$model->attributes = $_POST['Book'];
if ($publication == NULL) {
$publisher = new Publication();
$publisher->name = $_POST['Book']['publisher'];
$publisher->save();
$model->publisher = $publisher->publication_id;
} else {
$model->publisher = $publication->publication_id;
}
if ($model->save()) {
//echo count($authordetails).$authordetails->auth_id; exit;
if ($authordetails) {
$model->author = $authordetails->auth_id;
$model->save();
} else {
$author = new Author();
$author->author_name = $_POST['Book']['author'];
$author->save();
$model->author = $author->auth_id;
$model->save();
}
$model->status = 'C';
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Publication();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Publication'])) {
$model->attributes = $_POST['Publication'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->publication_id));
}
}
$this->render('create', array('model' => $model));
}
示例3: executeAdd
public function executeAdd(sfWebRequest $request)
{
$pubName = $request->getParameter("name");
$pubId = $request->getParameter("id", null);
if (!is_null($pubId)) {
$pub = PublicationPeer::retrieveByPk($pubId);
} else {
$pub = new Publication();
}
$pub->setName($pubName);
$pub->save();
$c = new Criteria();
$c->addAscendingOrderByColumn(PublicationPeer::NAME);
$pager = new sfPropelPager("Publication", sfConfig::get("app_items_per_page"));
$pager->setCriteria($c);
$pager->setPage(1);
$pager->init();
$this->renderPartial("renderList", array("pager" => $pager));
return sfView::NONE;
}
示例4: forward
$publication = get_entity($guid);
if (empty($publication)) {
register_error(elgg_echo('InvalidParameterException:GUIDNotFound', [$guid]));
forward('publications/all');
}
if (!$publication instanceof Publication || !$publication->canEdit()) {
forward('publications/all');
}
$new_entity = false;
} else {
$publication = new Publication();
$publication->owner_guid = elgg_get_logged_in_user_guid();
$publication->container_guid = (int) get_input('container_guid', elgg_get_logged_in_user_guid());
$publication->access_id = $access;
$publication->title = $title;
if (!$publication->save()) {
register_error(elgg_echo('publication:error'));
forward(REFERER);
}
}
$publication->access_id = $access;
$publication->title = $title;
if (!$publication->save()) {
register_error(elgg_echo('publication:error'));
forward(REFERER);
}
$publication->tags = $tags;
$publication->pubtype = $type;
// save custom data
foreach ($data as $key => $value) {
$publication->{$key} = $value;
示例5: createEvent
/**
* Creates an event on Facebook.
*
* @param string $title Title of the event.
* @param int $start Epoch timestamp for the event start.
* @param int $end Epoch timestamp for the event end.
* @param string $location Location of the event.
* @param string $description Description of the event.
* @param string $picture Local path (no URL) of the picture for the event.
*
* @return array Result set of the Facebook API call.
* @todo Standardise the result sets of connection API calls.
*/
public function createEvent($objectId, $title, $start, $end, $location, $description, $picture = null)
{
// Privacy types: OPEN, CLOSED, SECRET
$start = is_numeric($start) ? date("c", $start) : $start;
$end = is_numeric($end) ? date("c", $end) : $end;
$attachment = array("privacy_type" => "OPEN", "name" => $title, "host" => "Me", "start_time" => $start, "end_time" => $end, "location" => $location, "description" => $description);
if ($picture) {
$attachment[basename($picture)] = "@" . realpath($picture);
$this->api()->setFileUploadSupport(true);
}
try {
// TODO: support pages (page Id instead of "me")
$rs = $this->api()->api('me/events', 'post', $attachment);
} catch (Exception $e) {
Log::error("Exception: {$e}");
} catch (FacebookApiException $e) {
Log::debug("FacebookApiException {$e}, " . print_r($attachment, true) . print_r($this, true));
return null;
}
$publication = new Publication();
$publication->setObjectId($objectId);
$publication->setConnectionId($this->externalId);
$publication->setBody(serialize($attachment));
$publication->setResponse(serialize($rs));
if (isset($rs['id'])) {
list($uid, $postId) = explode("_", $rs['id']);
$publication->setExternalId($postId);
} else {
$result->error = $rs;
Log::debug("error: {$result->error}");
}
$publication->save();
return $rs;
// TODO: invites
// $fb->api( array(
// 'method' => 'events.invite',
// 'eid' => $event_id,
// 'uids' => $id_array,
// 'personal_message' => $message,
// ) );
}
示例6: 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->aPublication !== null) {
if ($this->aPublication->isModified() || $this->aPublication->isNew()) {
$affectedRows += $this->aPublication->save($con);
}
$this->setPublication($this->aPublication);
}
if ($this->aProject !== null) {
if ($this->aProject->isModified() || $this->aProject->isNew()) {
$affectedRows += $this->aProject->save($con);
}
$this->setProject($this->aProject);
}
if ($this->aStatus !== null) {
if ($this->aStatus->isModified() || $this->aStatus->isNew()) {
$affectedRows += $this->aStatus->save($con);
}
$this->setStatus($this->aStatus);
}
if ($this->isNew()) {
$this->modifiedColumns[] = JobPeer::ID;
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = JobPeer::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->setId($pk);
//[IMV] update autoincrement primary key
$this->setNew(false);
} else {
$affectedRows += JobPeer::doUpdate($this, $con);
}
$this->resetModified();
// [HL] After being saved an object is no longer 'modified'
}
if ($this->collJobAttachments !== null) {
foreach ($this->collJobAttachments as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->collPhotos !== null) {
foreach ($this->collPhotos as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->collDeliverys !== null) {
foreach ($this->collDeliverys as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->collJobPhotographers !== null) {
foreach ($this->collJobPhotographers as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->collJobClients !== null) {
foreach ($this->collJobClients as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例7: saveBookEditors
/**
* Save book editors with a publication
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param \Publication $entity supplied entity
*
* @return void
*/
public static function saveBookEditors($event, $type, $entity)
{
if (!$entity instanceof \Publication) {
return;
}
// cleanup book editors
$entity->deleteRelationships('book_editor');
unset($entity->book_editors);
$supported_types = ['book', 'inbook', 'incollection', 'proceedings', 'inproceedings'];
$type = get_input('type');
if (!in_array($type, $supported_types)) {
return;
}
$book_editors_guids = get_input('book_editors');
$book_editors_order = get_input('book_editors_order');
// save book editors
if (!empty($book_editors_guids)) {
foreach ($book_editors_guids as $book_editor) {
add_entity_relationship($entity->getGUID(), 'book_editor', $book_editor);
}
}
$pbook_editors = implode(',', $book_editors_order);
$entity->book_editors = $pbook_editors;
$entity->save();
}