本文整理匯總了PHP中type::update方法的典型用法代碼示例。如果您正苦於以下問題:PHP type::update方法的具體用法?PHP type::update怎麽用?PHP type::update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類type
的用法示例。
在下文中一共展示了type::update方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
/**
*
* @param array $data
* @param type $id
* @return type
*/
public function update(array $data, $id)
{
try {
$this->validator->with($data)->passesOrFail();
return $this->repository->update($data, $id);
} catch (ValidatorException $e) {
return ['error' => 'true', 'messege' => $e->getMessageBag()];
} catch (\Exception $e) {
return ['error' => 'true', 'messege' => "Usuário não encontrado!"];
}
}
示例2: saveArtist
/**
*
* @param \Music\Model\Artist $artist
* @throws \Exception
*/
public function saveArtist(Artist $artist)
{
$data = array('full_name' => $artist->getFullName(), 'year_found' => $artist->getYearFound(), 'origin' => $artist->getOrigin(), 'createdby' => $this->id);
$artist_id = (int) $artist->getArtistId();
if ($artist_id == 0) {
$this->tableGateway->insert($data);
} else {
if ($this->getArtist($artist_id)) {
//\Zend\Debug\Debug::dump($artist_id);
$this->tableGateway->update($data, array('artist_id' => $artist_id));
} else {
throw new \Exception('Form id does not exist');
}
}
}
示例3: update
/**
*
* @param Request $request
* @param type $id
*/
public function update(Request $request, $id)
{
$produto = $this->service->show($id);
if ($produto['error']) {
return redirect($this->url)->with("danger", $produto['messege']);
}
$this->service->update($request->all(), $id);
return redirect($this->url)->with("success", "Produto atualizado!");
}
示例4: updateContact
/**
* Updates a contact
* @param array $data
* @param int $id
* @return boolean
*/
public function updateContact($data, $id)
{
try {
$this->tableGateway->update($data, array('contact_id' => $id));
return true;
} catch (Exception $e) {
return false;
}
}
示例5: update
/**
* 修改數據
* @param array $entity 鍵值組成的數組
* @param array $whereData 一維數組或k、v、s結構組成的數組。一維數組元素之間為and關係,鍵和值為等於關係;k、v、s結構數組,k:屬性名,v:屬性值,s:屬性名和屬性值之間的操作符
* @param string $table 修改數據的表,若為空,修改默認表數據
* @param array $filter 認為是表達式的鍵,$entity的鍵在該參數中時,認為$entity相應鍵對應的值是表達式
* @param boolean $isReturnAffectedRows 是否返回刪除記錄的條數,默認是不返回
* @return boolean
*/
public function update(array $entity, $whereData = array(), $table = '', $isReturnAffectedRows = 0, array $filter = array())
{
if (is_null($this->db)) {
$this->db = \Util\Db\Manager::getInstance($this->dbName);
}
//如果方法中沒傳遞表名,則向默認表中插入數據
$table = is_string($table) && $table != '' ? $table : $this->defaultTable;
$state = $this->db->update($entity, $table, $whereData, $filter);
if ($isReturnAffectedRows && $state) {
return $this->db->getAffectedRows();
}
return $state;
}
示例6: reset
private function reset(Section $section = null)
{
if (null != $section) {
// Get default values for section
$names = array();
foreach ($section->fields as $field) {
if ($field instanceof ValueFieldInterface) {
$names[] = $field->get_name();
}
}
$this->options->update($this->updater->reset($names));
} else {
// No values are passed to the OptionsUpdater so that the default values
// Will be returned.
$this->options->update($this->updater->reset());
}
}
示例7: save
/**
* Save
*
* @return integer
*/
public function save()
{
if (is_array($this->primaryKey)) {
// @todo compound primary keys
}
if (isset($this->originalData[$this->primaryKey])) {
// UPDATE
$where = array($this->primaryKey => $this->originalData[$this->primaryKey]);
$data = $this->currentData;
unset($data[$this->primaryKey]);
$rowsAffected = $this->tableGateway->update($data, $where);
} else {
// INSERT
$rowsAffected = $this->tableGateway->insert($this->currentData);
$primaryKey = $this->tableGateway->getLastInsertId();
$where = array($this->primaryKey => $primaryKey);
}
// refresh data
$result = $this->tableGateway->select($where);
$rowData = $result->current();
$this->populateOriginalData($rowData);
return $rowsAffected;
}
示例8: update
/**
*
* @param Request $request
* @param type $id
*/
public function update(Request $request, $id)
{
$this->service->update($request->all(), $id);
}
示例9: update
/**
*
* @param User $entity
* @return type
*/
public function update(User $entity)
{
$result = $this->cbo->update($entity);
return $result;
}
示例10: makeInput
/**
*
* @param type $answer
* @param type $results
* @param type $options
* @param type $form
* @return string
*/
public function makeInput($answer, $results = null, $options = [], $form = '')
{
$html = '';
$type = $answer->type;
$name = $answer->akey;
$text = !empty($answer->text) ? _t(ucfirst($answer->text)) : '';
$ansval = $answer->value;
$section = $answer->question->section;
$qslug = $answer->question->slug;
$qid = $answer->question->id;
if (empty($answer->slug)) {
$answer->update(['slug' => snake_case($answer->akey)]);
}
$ans_slug = $answer->slug;
$options['id'] = $ans_slug;
$options['data-logic'] = json_encode($answer->logic);
$value = null;
if (!is_null($results)) {
$rs = $results->where('section_id', $section)->first();
if (!is_null($rs)) {
foreach ($rs->answers as $values) {
if (in_array($ans_slug, $values->toArray())) {
if ($type == 'radio') {
$value = true;
} else {
$value = $values->value;
}
break;
} else {
$value = null;
}
}
}
} else {
$value = null;
}
if ($type == 'radio') {
$inputname = "answer[{$section}][{$qslug}][radio]";
} else {
$inputname = "answer[{$section}][{$qslug}][{$ans_slug}]";
}
if (array_key_exists('class', $options)) {
$cssClass = $options['class'];
} else {
$cssClass = '';
}
switch ($type) {
case 'radio':
$options['data-value'] = $ansval;
$html .= "<div class=\"radio\">";
$html .= "<label class='control-label'>";
$html .= $this->radio($inputname, $ans_slug, $value, $options);
$html .= "<span class='badge'>{$ansval}</span> ";
$html .= $text;
$html .= "</label>";
$html .= "</div>";
break;
case 'checkbox':
$html .= "<div class=\"checkbox\">";
$html .= "<label class='control-label'>";
$html .= $this->checkbox($inputname, $ansval, $value, $options);
$html .= "<span class='badge'>{$ansval}</span> ";
$html .= $text;
$html .= "</label>";
$html .= "</div>";
break;
case 'textarea':
$options['class'] = $cssClass . ' form-control';
$html .= "<label for=\"{$inputname}\" class='col-xs-2 text-normal'>{$text}</label>";
$html .= "<div class='col-xs-10' style='padding-left:0px'>";
$html .= $this->textarea($inputname, $value, $options);
$html .= "</div>";
break;
case 'option':
break;
case 'question':
break;
default:
$options['class'] = $cssClass . ' form-control';
$html .= "<label style='padding-left:0px;margin-top:15px' for=\"{$inputname}\" class='col-xs-3 text-normal'>{$text}</label>";
$html .= "<div style='padding-left:0px;margin-top:15px' class='col-xs-9' style='padding-left:0px'>";
$html .= $this->input($type, $inputname, $value, $options);
$html .= "</div>";
break;
}
return $html;
}
示例11: update
/**
*
* @param Subsecretaria $subsecretaria
* @return type
*/
public function update(Subsecretaria $subsecretaria)
{
$result = $this->subsecretariaDAO->update($subsecretaria);
return $result;
}
示例12: update
/**
*
* @param Permissao $entity
* @return type
*/
public function update(Permissao $entity)
{
$result = $this->cbo->update($entity);
return $result;
}
示例13: update
/**
*
* @param Setores $setores
* @return type
*/
public function update(Setores $setores)
{
$result = $this->setoresDAO->update($setores);
return $result;
}
示例14: updateModelWithFormValidation
/**
* @param type $form
* @param type $model
* @param type $successMsg
* @return boolean
* @throws InvalidArgumentException
*/
protected function updateModelWithFormValidation($form, $model, $successMsg)
{
if ($form->isValid() && $model->update()) {
if (!empty($successMsg)) {
$this->flashSession->notice($successMsg);
}
return true;
}
$m = "";
foreach ($form->getMessages() as $msg) {
$m .= $msg . "<br>";
}
foreach ($model->getMessages() as $msg) {
$m .= $msg . "<br>";
}
throw new InvalidArgumentException($m);
}
示例15: update
/**
*
* @param Encaminhamentos $encaminhamentos
* @return type
*/
public function update(Encaminhamentos $encaminhamentos)
{
$result = $this->encaminhamentosDAO->update($encaminhamentos);
return $result;
}