本文整理汇总了PHP中Document::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Document::save方法的具体用法?PHP Document::save怎么用?PHP Document::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document
的用法示例。
在下文中一共展示了Document::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRevisionSave
function testRevisionSave()
{
$ret = $GLOBALS['db']->query("SELECT COUNT(*) AS rowcount1 FROM document_revisions WHERE document_id = '{$this->doc->id}'");
$row = $GLOBALS['db']->fetchByAssoc($ret);
$this->assertEquals($row['rowcount1'], 0, 'We created an empty revision');
$ret = $GLOBALS['db']->query("SELECT document_revision_id FROM documents WHERE id = '{$this->doc->id}'");
$row = $GLOBALS['db']->fetchByAssoc($ret);
$this->assertTrue(empty($row['document_revision_id']), 'We linked the document to a fake document_revision');
$ds = new DocumentSoap();
$revision_stuff = array('file' => base64_encode('Pickles has an extravagant beard of pine fur.'), 'filename' => 'a_file_about_pickles.txt', 'id' => $this->doc->id, 'revision' => '1');
$revisionId = $ds->saveFile($revision_stuff);
$ret = $GLOBALS['db']->query("SELECT COUNT(*) AS rowcount1 FROM document_revisions WHERE document_id = '{$this->doc->id}'");
$row = $GLOBALS['db']->fetchByAssoc($ret);
$this->assertEquals($row['rowcount1'], 1, 'We didn\'t create a revision when we should have');
$ret = $GLOBALS['db']->query("SELECT document_revision_id FROM documents WHERE id = '{$this->doc->id}'");
$row = $GLOBALS['db']->fetchByAssoc($ret);
$this->assertEquals($row['document_revision_id'], $revisionId, 'We didn\'t link the newly created document revision to the document');
// Double saving doesn't work because save doesn't reset the new_with_id
$newDoc = new Document();
$newDoc->retrieve($this->doc->id);
$newDoc->document_revision_id = $revisionId;
$newDoc->save(FALSE);
$ret = $GLOBALS['db']->query("SELECT COUNT(*) AS rowcount1 FROM document_revisions WHERE document_id = '{$this->doc->id}'");
$row = $GLOBALS['db']->fetchByAssoc($ret);
$this->assertEquals($row['rowcount1'], 1, 'We didn\'t create a revision when we should have');
$ret = $GLOBALS['db']->query("SELECT document_revision_id FROM documents WHERE id = '{$this->doc->id}'");
$row = $GLOBALS['db']->fetchByAssoc($ret);
$this->assertEquals($row['document_revision_id'], $revisionId, 'We didn\'t link the newly created document revision to the document');
}
示例2: saveFile
function saveFile($document, $portal = false)
{
global $sugar_config;
$focus = new Document();
if (!empty($document['id'])) {
$focus->retrieve($document['id']);
} else {
return '-1';
}
if (!empty($document['file'])) {
$decodedFile = base64_decode($document['file']);
$this->upload_file->set_for_soap($document['filename'], $decodedFile);
$ext_pos = strrpos($this->upload_file->stored_file_name, ".");
$this->upload_file->file_ext = substr($this->upload_file->stored_file_name, $ext_pos + 1);
if (in_array($this->upload_file->file_ext, $sugar_config['upload_badext'])) {
$this->upload_file->stored_file_name .= ".txt";
$this->upload_file->file_ext = "txt";
}
$revision = new DocumentRevision();
$revision->filename = $this->upload_file->get_stored_file_name();
$revision->file_mime_type = $this->upload_file->getMimeSoap($revision->filename);
$revision->file_ext = $this->upload_file->file_ext;
//$revision->document_name = ;
$revision->revision = $document['revision'];
$revision->document_id = $document['id'];
$revision->save();
$focus->document_revision_id = $revision->id;
$focus->save();
$return_id = $revision->id;
$this->upload_file->final_move($revision->id);
} else {
return '-1';
}
return $return_id;
}
示例3: save
function save($id = FALSE)
{
if ($_POST) {
$document = new Document($id);
$_POST['user_id'] = $this->session->userdata('id');
$_POST['start_date'] = Date2DB($_POST['start_date']);
$document->from_array($_POST);
$document->save();
fix_file($_FILES['file']);
foreach ($_POST['doc'] as $key => $doc) {
if (@$_FILES['file'][$key]['name'] || @$_POST['doc_id'][$key]) {
$document_file = new Document_file(@$_POST['doc_id'][$key]);
if ($_FILES['file'][$key]['name']) {
if (@$_POST['doc_id'][$key]) {
$document_file->delete_file('uploads/document', 'file');
}
$document_file->file = $document_file->upload($_FILES['file'][$key], 'uploads/document');
}
$document_file->name = $doc;
$document_file->document_id = $document->id;
$document_file->save();
}
}
set_notify('success', lang('save_data_complete'));
}
redirect('documents');
}
示例4: run
public function run($type, $id, $contentKey = null, $user)
{
if (isset($_FILES['avatar'])) {
$type = trim($type);
$folder = str_replace(DIRECTORY_SEPARATOR, "/", DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . $id . DIRECTORY_SEPARATOR);
$pathImage = $this->processImage($_FILES['avatar'], $id, $type);
if ($pathImage) {
$params = array();
$params["id"] = $id;
$params["type"] = $type;
$params['folder'] = $folder;
$params['moduleId'] = Yii::app()->controller->module->id;
$params['name'] = $pathImage["name"];
$params['doctype'] = "image";
$params['size'] = $pathImage["size"][0] * $pathImage["size"][1] / 1000;
$params['author'] = $user;
$params['category'] = array();
$params['contentKey'] = $contentKey;
$result = Document::save($params);
//Profile to check
$urlBdd = str_replace(DIRECTORY_SEPARATOR, "/", DIRECTORY_SEPARATOR . "upload" . DIRECTORY_SEPARATOR . Yii::app()->controller->module->id . $folder . $pathImage["name"]);
Document::setImagePath($id, $type, $urlBdd, $contentKey);
$newImage = Document::getById($result["id"]);
}
$res = array('result' => true, 'msg' => 'The picture was uploaded', 'imagePath' => $urlBdd, "id" => $result["id"], "image" => $newImage);
Rest::json($res);
Yii::app()->end();
}
}
示例5: save
/**
* Save Document
* @param [type] $data [description]
* @param array $options [description]
* @return [type] [description]
*/
public function save(array &$data, array $options = array())
{
$document = new Document($data, $this);
$save = $document->save($options);
$data = $document->data;
return $save;
}
示例6: addNews
public function addNews()
{
foreach ($this->fileArray as $file) {
$title = explode(".", $file)[0];
$book = new Document($this->path, $file, $title);
$book->save();
}
}
示例7: setUp
public function setUp()
{
global $current_user, $currentModule;
$mod_strings = return_module_language($GLOBALS['current_language'], "Documents");
$current_user = SugarTestUserUtilities::createAnonymousUser();
$document = new Document();
$document->id = uniqid();
$document->name = 'Test Document';
$document->save();
$this->doc = $document;
}
示例8: create
function create()
{
$document = new Document();
$document->organization_id = $_SESSION['organization_id'];
$document->name = $_POST['name'];
$document->year = $_POST['year'];
if ($document->save()) {
$this->redirect('/documents/' . $document->id);
} else {
$this->redirect('/documents');
}
}
示例9: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Document();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Document'])) {
$model->attributes = $_POST['Document'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->ID));
}
}
$this->render('create', array('model' => $model));
}
示例10: create
function create()
{
$document = new Document();
$document->organization_id = $_SESSION['organization_id'];
$document->name = $_POST['name'];
$document->year = $_POST['year'];
$document->logo = '381554527568a0188078c34.22685210ibip.jpg';
if ($document->save()) {
$document->generate($this->sections);
$this->redirect('/documents/' . $document->id);
} else {
$this->redirect('/documents');
}
}
示例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 corresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aJournalEntry !== null) {
if ($this->aJournalEntry->isModified() || $this->aJournalEntry->isNew()) {
$affectedRows += $this->aJournalEntry->save($con);
}
$this->setJournalEntry($this->aJournalEntry);
}
if ($this->aDocument !== null) {
if ($this->aDocument->isModified() || $this->aDocument->isNew()) {
$affectedRows += $this->aDocument->save($con);
}
$this->setDocument($this->aDocument);
}
if ($this->aUserRelatedByCreatedBy !== null) {
if ($this->aUserRelatedByCreatedBy->isModified() || $this->aUserRelatedByCreatedBy->isNew()) {
$affectedRows += $this->aUserRelatedByCreatedBy->save($con);
}
$this->setUserRelatedByCreatedBy($this->aUserRelatedByCreatedBy);
}
if ($this->aUserRelatedByUpdatedBy !== null) {
if ($this->aUserRelatedByUpdatedBy->isModified() || $this->aUserRelatedByUpdatedBy->isNew()) {
$affectedRows += $this->aUserRelatedByUpdatedBy->save($con);
}
$this->setUserRelatedByUpdatedBy($this->aUserRelatedByUpdatedBy);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例12: test_file_field_read_and_write
public function test_file_field_read_and_write()
{
$file = new File("/tmp/test.txt");
$user = User::find_by_email("ben@allseeing-i.com");
$document = new Document();
$document->user = $user;
$document->last_modified = new Date();
$document->file = $file;
$document->save();
FuzzyTest::assert_true($file->exists(), "File not written");
$document = Document::find_by_id($document->id);
$result = is_a($document->file, "File");
FuzzyTest::assert_true($result, "File not read correctly");
$contents = $document->file->read();
FuzzyTest::assert_equal($contents, "This is the content of the file", "File not read correctly");
}
示例13: saveModel
protected function saveModel($document = false)
{
if (Input::get('id')) {
$document = Document::find(Input::get('id'));
}
if (!$document) {
$document = new Document();
}
$document->type = Input::get('type');
$document->title = Input::get('title');
$document->description = Input::get('description');
$document->url = Input::get('url');
$document->meta = Input::get('meta');
$document->save();
return $document;
}
示例14: add
public function add($post, $path)
{
$model = new Document();
$model->setAttributes($post);
if (!empty($path)) {
if (empty($post['name'])) {
$model->name = $path['name'];
}
$model->path = $path['path'];
}
$model->created_at = time();
$model->updated_at = time();
if ($model->save(FALSE)) {
return TRUE;
}
return FALSE;
}
示例15: executeJustificatif
public function executeJustificatif(sfWebRequest $request)
{
$note_de_frais = $this->getRoute()->getObject();
$user = $this->getUser();
$asso = $note_de_frais->getAsso();
$this->checkAuthorisation($asso);
$html = $this->getPartial('noteDeFrais/pdf', compact(array('note_de_frais', 'asso', 'user')));
$nom = $note_de_frais->getPrimaryKey() . '-' . date('Y-m-d-H-i-s') . '-' . Doctrine_Inflector::urlize($note_de_frais->getNom());
$doc = new Document();
$doc->setNom('Attestation à signer');
$doc->setAsso($asso);
$doc->setUser($this->getUser()->getGuardUser());
$doc->transaction_id = $note_de_frais->transaction_id;
$doc->setTypeFromSlug('note_de_frais');
$path = $doc->generatePDF('Note de frais', $nom, $html);
$doc->save();
header('Content-type: application/pdf');
readfile($path);
return sfView::NONE;
}