本文整理汇总了PHP中Item::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::save方法的具体用法?PHP Item::save怎么用?PHP Item::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make(Input::all(), array('company_id' => 'required', 'name' => 'required', 'description' => 'required', 'url' => 'required|url', 'photo' => 'required|image'));
if ($validator->fails()) {
return Response::json($validator->messages(), 400);
}
$item = new Item();
$item->company_id = Input::get('company_id');
$item->name = Input::get('name');
$item->description = Input::get('description');
$item->url = Input::get('url');
//temporary for territory
$item->territory_id = 1;
$item->save();
//save tags if available
foreach (Input::get('tag') as $tagid) {
$item->tags()->attach($tagid);
}
$image = Input::file('photo');
$filename = $item->id;
$saveBigUrl = base_path() . '/public/images/items/' . $filename . '.jpg';
$saveMediumUrl = base_path() . '/public/images/items/' . $filename . '_medium.jpg';
$saveSmallUrl = base_path() . '/public/images/items/' . $filename . '_small.jpg';
Image::make($image->getRealPath())->fit(600, null, function ($constraint) {
//for big image
$constraint->upsize();
})->save($saveBigUrl, 50)->fit(300)->save($saveMediumUrl, 50)->fit(100)->save($saveSmallUrl, 50);
$item->big_image_url = url('images/items/' . $filename . '.jpg');
$item->medium_image_url = url('images/items/' . $filename . '_medium.jpg');
$item->small_image_url = url('images/items/' . $filename . '_small.jpg');
$item->save();
return Response::json(array('success_code' => 'OK', 'data' => $item->toArray()), 200);
}
示例2: setUp
/**
* Set ups up for each test.
*
* @return void
* @author Eric Rochester <erochest@virginia.edu>
**/
public function setUp()
{
parent::setUp();
$this->_todel = array();
$this->user = $this->db->getTable('user')->find(1);
$this->_authenticateUser($this->user);
$this->phelper = new Omeka_Test_Helper_Plugin();
$this->phelper->setUp('NeatlineFeatures');
$this->_dbHelper = Omeka_Test_Helper_Db::factory($this->application);
// Retrieve the element for some DC fields.
$el_table = get_db()->getTable('Element');
$this->_title = $el_table->findByElementSetNameAndElementName('Dublin Core', 'Title');
$this->_subject = $el_table->findByElementSetNameAndElementName('Dublin Core', 'Subject');
$this->_coverage = $el_table->findByElementSetNameAndElementName('Dublin Core', 'Coverage');
$this->_cutil = new NeatlineFeatures_Utils_View();
$this->_cutil->setEditOptions(null, $this->_coverage, "", "Elements[38][0]", 0);
$this->_item = new Item();
$this->_item->save();
$this->toDelete($this->_item);
$t1 = $this->addElementText($this->_item, $this->_title, '<b>A Title</b>', 1);
$t2 = $this->addElementText($this->_item, $this->_subject, 'Subject');
$this->toDelete($t1);
$this->toDelete($t2);
$this->_item->save();
}
示例3: store
public function store()
{
try {
$addModel = Input::json()->all();
//select the vendor name of the new selected vendor
$vendorQueryResult = Vendor::find($addModel['vendor_id']);
$newVendorName = $vendorQueryResult->name;
//creates the new item, sets the properties, and saves it
$addItem = new Item();
$addItem->description = $addModel['description'];
$addItem->email_threshold = $addModel['email_threshold'];
$addItem->item_url = $addModel['item_url'];
$addItem->name = $addModel['name'];
$addItem->on_order_quantity = $addModel['on_order_quantity'];
$addItem->quantity = $addModel['quantity'];
$addItem->vendor_id = $addModel['vendor_id'];
$addItem->active = 1;
$addItem->save();
$addItem->adjustmentQty = 0;
$addItem->vendor_name = $newVendorName;
return $addItem->toJson();
} catch (Exception $e) {
return json_encode('{"error":{"text":' . $e->getMessage() . '}}');
}
}
示例4: processFile
function processFile($filename)
{
//extract the filename to get the exact filename on the folder
$newFile = substr($filename, 3);
$dirname = substr($filename, 0, 2);
$fs = new Filesystem();
if ($fs->exists('../Repo/' . $dirname . '/' . $newFile)) {
$xml = simplexml_load_file('../Repo/' . $dirname . '/' . $newFile, null, LIBXML_NOCDATA);
$newXML = json_decode(json_encode($xml), true);
$data = formulateData($newXML, $dirname);
//insert data to db
$po = new PurchaseOrder();
$po->setFilename($newFile);
$po->setStore($dirname);
$po->setCustomerCode($data['customer_code']);
$po->setDeliveryDate($data['delivery_date']);
$po->setNumber($data['number']);
$po->save();
$po_id = $po->getId();
//insert all items
foreach ($data['items'] as $key => $value) {
$items = new Item();
$items->setPurchaseOrderId($po_id);
$items->setUpc($value['upc']);
$items->setQty($value['qty']);
$items->setQty($value['discount']);
$items->save();
}
$formulated_data = formulateData($newXML, $dirname);
$formulated_data['id'] = $po_id;
//print_r($formulated_data);
return $formulated_data;
}
}
示例5: save_new_item_to_wardrobe
public static function save_new_item_to_wardrobe()
{
self::check_logged_in();
$params = $_POST;
// Alustetaan uusi Item-luokan olion käyttäjän syöttämillä arvoilla
// Tallennetaan erikseen attribuutit muuttujaan..
$attributes = array('type' => $params['type'], 'brand' => $params['brand'], 'color' => $params['color'], 'color_2nd' => $params['color_2nd'], 'material' => $params['material'], 'image' => $params['image']);
//..ja luodaan olio attributestaulukon avulla
$item = new Item($attributes);
// kutsutaan item:in metodia errors, joka tarkistaa olivatko
// attribuutit valideja
$errors = $item->errors();
if (count($errors) == 0) {
// Validi item, tallennetaan
// Kutsutaan alustamamme olion save metodia, joka tallentaa olion tietokantaan
$item->save();
//tallennetaan mys käyttäjän vaatekaappiin
Wardrobe::add_item_for_person($item->item_id, $_SESSION['user']);
// Ohjataan käyttäjä lisäyksen jälkeen vaatteen esittelysivulle
Redirect::to('/wardrobe/wardrobe.html', array('message' => 'Item added to your wardrobe!'));
} else {
// Invalidi syöte
// Luodaan uusi näkymä johon välitetään syötetyt arvot
View::make('wardrobe/new_item.html', array('errors' => $errors, 'attributes' => $attributes));
}
}
示例6: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$item = new Item();
$detil_item = new DetilItem();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Item'], $_POST['DetilItem'])) {
$item->attributes = $_POST['Item'];
$detil_item->attributes = $_POST['DetilItem'];
if ($item->validate() & $detil_item->validate()) {
$connection = Yii::app()->db;
$transaction = $connection->beginTransaction();
try {
if ($item->save()) {
$detil_item->setAttribute('ID_ITEM', $item->ID_ITEM);
$detil_item->setAttribute('TANGGAL_INPUT', date('Y-m-d H:i:s'));
if ($detil_item->save()) {
$transaction->commit();
Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
$this->redirect(array('view', 'id' => $item->ID_ITEM));
}
}
} catch (Exception $e) {
$transaction->rollback();
Yii::app()->user->setFlash('info', MyFormatter::alertDanger('<strong>Error!</strong> Data gagal untuk disimpan.' . $e->getMessage()));
}
}
}
$this->render('create', array('item' => $item, 'detil_item' => $detil_item));
}
示例7: saveItem
/**
* Save Item
*
* @param Item $item
* @throws DaoException
*/
public function saveItem(Item $item)
{
try {
$item->save();
} catch (Exception $e) {
throw new DaoException($e->getMessage(), $e->getCode(), $e);
}
}
示例8: add_item
public function add_item($book_id, $quantity = 1)
{
$item = new Item();
$item->book_id = $book_id;
$item->cart_id = $this->id;
$item->quantity = $quantity;
$item->save();
}
示例9: postNewItem
public function postNewItem($f3)
{
$new_item = new Item($f3->get('DB'));
$new_item->label = $f3->get('POST["label"]');
$new_item->price = $f3->get('POST["price"]');
$new_item->quantity = $f3->get('POST["quantity"]');
$new_item->discount = $f3->get('POST["discount"]');
$new_item->type = $f3->get('POST["type"]');
$new_item->save();
}
示例10: array
function item_post()
{
$message = array('id' => $this->get('id'), 'title' => $this->post('title'));
$item = new Item();
$item->title = $this->post('title');
$item->datetime = $this->post('datetime');
$item->save();
$this->response($message, 200);
// 200 being the HTTP response code
}
示例11: add
public function add()
{
$item = new Item();
$item->user_id = $this->session->userdata('id');
$item->item = $this->input->post('listing-title');
$item->description = $this->input->post('listing-body');
$item->asking = $this->input->post('listing-asking');
$item->save();
// Redirect to view mode
header('Location: /marketplace');
}
示例12: 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->aEmpresa !== null) {
if ($this->aEmpresa->isModified() || $this->aEmpresa->isNew()) {
$affectedRows += $this->aEmpresa->save($con);
}
$this->setEmpresa($this->aEmpresa);
}
if ($this->aItem !== null) {
if ($this->aItem->isModified() || $this->aItem->isNew()) {
$affectedRows += $this->aItem->save($con);
}
$this->setItem($this->aItem);
}
if ($this->isNew()) {
$this->modifiedColumns[] = DocumentoPeer::ID_DOCUMENTO;
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = DocumentoPeer::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->setIdDocumento($pk);
//[IMV] update autoincrement primary key
$this->setNew(false);
} else {
$affectedRows += DocumentoPeer::doUpdate($this, $con);
}
$this->resetModified();
// [HL] After being saved an object is no longer 'modified'
}
if ($this->collHistoricoDocumentos !== null) {
foreach ($this->collHistoricoDocumentos as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$input = Input::get('text');
$item = new Item();
$item->text = $input;
$item->save();
if ($item) {
return 1;
} else {
return 0;
}
}
示例14: run
public function run()
{
$item = new Item();
$item->item_name = 'Thuderfury, Blessed Blade of the Windseeker';
$item->item_type = 'Weapon';
$item->date_listed = '1902-05-22';
$item->price = '150.00';
$item->unit = 'g';
$item->description = 'Did someone say Thunderfury? Legendary! ';
$item->item_number = '19019';
$item->save();
}
示例15: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$input = Input::get('name');
$item = new Item();
$item->name = $input;
$item->save();
if ($item) {
return $item->id;
} else {
return 0;
}
}