本文整理汇总了PHP中Branch::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Branch::save方法的具体用法?PHP Branch::save怎么用?PHP Branch::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Branch
的用法示例。
在下文中一共展示了Branch::save方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit(Branch $model)
{
if (isset($_POST['Branch']) && $_POST['Branch']) {
$model->attributes = $_POST['Branch'];
if ($model->save()) {
$params = ['id' => $model->bra_id];
$params['close'] = false;
if (isset($_POST['close'])) {
$params['close'] = true;
}
if (isset($_GET['callback']) && $_GET['callback']) {
Yii::app()->user->setFlash('branch-callback', true);
$params['callback'] = $_GET['callback'];
}
Yii::app()->user->setFlash('branch-update-success', 'Branch info updated');
$this->redirect($this->createUrl('Update', $params));
}
}
if (Yii::app()->user->getFlash('branch-callback')) {
$callback = new PopupCallback($_GET['callback']);
$callback->run([$model->bra_id], isset($_GET['close']) && $_GET['close']);
} elseif (isset($_GET['close']) && $_GET['close']) {
echo '<script>window.close();</script>';
}
$this->render('edit', array('model' => $model));
}
示例2: add
public static function add($data)
{
$Branch = new Branch();
foreach ($data as $field => $value) {
$Branch->{$field} = $value;
}
return $Branch->save();
}
示例3: store
/**
* Store a newly created branch in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make($data = Input::all(), Branch::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$branch = new Branch();
$branch->name = Input::get('name');
$branch->save();
return Redirect::route('branches.index');
}
示例4: actionCreate
/**
* Создает новую модель Филиала.
* Если создание прошло успешно - перенаправляет на просмотр.
*
* @return void
*/
public function actionCreate()
{
$model = new Branch();
if (Yii::app()->getRequest()->getPost('Branch') !== null) {
$model->setAttributes(Yii::app()->getRequest()->getPost('Branch'));
if ($model->save()) {
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('BranchModule.branch', 'Запись добавлена!'));
$this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
}
}
$this->render('create', ['model' => $model]);
}
示例5: run
public function run()
{
DB::table('branchs')->truncate();
$branch = new Branch();
$branch->name = "Giày dép";
$branch->save();
$branch = new Branch();
$branch->name = "Áo quần";
$branch->save();
$branch = new Branch();
$branch->name = "Phụ kiện";
$branch->save();
}
示例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->asfGuardUser !== null) {
if ($this->asfGuardUser->isModified() || $this->asfGuardUser->isNew()) {
$affectedRows += $this->asfGuardUser->save($con);
}
$this->setsfGuardUser($this->asfGuardUser);
}
if ($this->aRepository !== null) {
if ($this->aRepository->isModified() || $this->aRepository->isNew()) {
$affectedRows += $this->aRepository->save($con);
}
$this->setRepository($this->aRepository);
}
if ($this->aBranch !== null) {
if ($this->aBranch->isModified() || $this->aBranch->isNew()) {
$affectedRows += $this->aBranch->save($con);
}
$this->setBranch($this->aBranch);
}
if ($this->aFile !== null) {
if ($this->aFile->isModified() || $this->aFile->isNew()) {
$affectedRows += $this->aFile->save($con);
}
$this->setFile($this->aFile);
}
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;
}
示例7: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Branch();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Branch'])) {
$model->attributes = $_POST['Branch'];
$model->created_by = Yii::app()->session->get('user_id');
$model->created_on = date('Y-m-d H:i:s');
$model->modified_by = Yii::app()->session->get('user_id');
$model->modified_on = date('Y-m-d H:i:s');
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例8: actionCreate
/**
* Создает новую модель Филиала.
* Если создание прошло успешно - перенаправляет на просмотр.
*
* @return void
*/
public function actionCreate()
{
$roles = ['1'];
$role = \Yii::app()->user->role;
if (array_intersect($role, $roles)) {
$model = new Branch();
if (Yii::app()->getRequest()->getPost('Branch') !== null) {
$model->setAttributes(Yii::app()->getRequest()->getPost('Branch'));
if ($model->save()) {
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('BranchModule.branch', 'Запись добавлена!'));
$this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
}
}
$this->render('create', ['model' => $model]);
} else {
throw new CHttpException(403, 'Ошибка прав доступа.');
}
}
示例9: postAdd
public function postAdd()
{
$validator = Validator::make(Input::all(), Branch::$rules);
if ($validator->fails()) {
return Redirect::to('branch/add')->withErrors($validator)->withInput();
}
$branch = new Branch();
$branch->name = Input::get('name');
$branch->type_id = Input::get('type_id');
$branch->area_id = Input::get('area_id');
$branch->line_id = Input::get('line_id');
$branch->user_id = Input::get('user_id');
$branch->contact = Input::get('contact');
$branch->mobile = Input::get('mobile');
$type = Type::find(Input::get('type_id'));
$area = Area::find(Input::get('area_id'));
$line = Line::find(Input::get('line_id'));
$branch->day = $type->day;
$sourceNumber = DB::table('branch')->max('id');
$newNumber = $this->__codeNumber($sourceNumber);
if (Input::get('stock') > 0) {
$branch->stock = Input::get('stock');
}
$branch->code = $type->code . $area->code . $line->code . $newNumber;
$branch->address = $area->name . $line->name . Input::get('address');
$branch->last_visit_at = $branch->last_ship_at = $this->__time();
$branch->check = '1';
$branch->save();
// if (Input::get('stock') > 0)
// {
// $branch_good = new BranchGood();
// $branch_good->branch_id = $branch->id;
// $branch_good->pay_status = '0';
// $branch_good->stock = Input::get('stock');
// $branch_good->memo = Input::get('memo');
// $branch_good->save();
// }
return Redirect::to('branch')->with('success', '网点添加成功!');
}
示例10: executeBulkupload
public function executeBulkupload()
{
if ($this->getRequest()->getFileName('csvfile')) {
$fileName = md5($this->getRequest()->getFileName('csvfile') . time() . rand(0, 99999));
$ext = $this->getRequest()->getFileExtension('csvfile');
$this->getRequest()->moveFile('csvfile', sfConfig::get('sf_upload_dir') . "//csvfiles//" . $fileName . ".csv");
$fullname = $fileName . ".csv";
//$fullpath = '/uploads/csvfiles/'.$fullname;
$fp = sfConfig::get('sf_upload_dir') . "//csvfiles//" . $fileName . ".csv";
$reader = new sfCsvReader($fp, ',', '"');
$reader->open();
$i = 1;
$exist;
$ignore;
$log;
$ignoreflag = 0;
$success = 0;
while ($data = $reader->read()) {
$name[] = array();
$name = explode(' ', $data[0]);
$roll = $data[1];
$enrol = $data[2];
$branch = $data[3];
$degree = $data[4];
$year = $data[5];
$c = new Criteria();
$c->add(UserPeer::ENROLMENT, $enrol);
$user = UserPeer::doSelectOne($c);
if (!$user) {
$c = new Criteria();
$c->add(BranchPeer::CODE, $branch);
$br = BranchPeer::doSelectOne($c);
if (!$br) {
$br = new Branch();
$br->setName($branch);
$br->setCode($branch);
$br->save();
}
$c = new Criteria();
$c->add(DegreePeer::NAME, $degree);
$dg = DegreePeer::doSelectOne($c);
if (!$dg) {
$dg = new Degree();
$dg->setName($degree);
$dg->save();
}
$user = new User();
if ($roll) {
$user->setRoll($roll);
$user->setRollflag(sfConfig::get('app_defaultprivacy_roll'));
}
if ($enrol) {
$user->setEnrolment($enrol);
$user->setEnrolflag(sfConfig::get('app_defaultprivacy_enrol'));
} else {
$ignoreflag = 1;
}
if ($year) {
$user->setGraduationyear($year);
$user->setGraduationyearflag(sfConfig::get('app_defaultprivacy_year'));
}
$user->setBranchId($br->getId());
$user->setBranchflag(sfConfig::get('app_defaultprivacy_branch'));
$user->setDegreeId($dg->getId());
$user->setDegreeflag(sfConfig::get('app_defaultprivacy_degree'));
$user->setIslocked(sfConfig::get('app_islocked_unclaimed'));
$user->setUsertype(sfConfig::get('app_usertypecode_Alumni'));
$lastname = '';
$personal = new Personal();
$name[0] = str_replace('.', '', $name[0]);
$personal->setFirstname($name[0]);
if ($name[3]) {
$name[1] = str_replace('.', '', $name[1]);
$name[2] = str_replace('.', '', $name[2]);
$name[3] = str_replace('.', '', $name[3]);
$midname = $name[1] . " " . $name[2];
$personal->setMiddlename($midname);
$personal->setLastname($name[3]);
$lastname = $name[3];
} elseif ($name[2]) {
$name[1] = str_replace('.', '', $name[1]);
$name[2] = str_replace('.', '', $name[2]);
$personal->setMiddlename($name[1]);
$personal->setLastname($name[2]);
$lastname = $name[2];
} elseif ($name[1]) {
$name[1] = str_replace('.', '', $name[1]);
$personal->setLastname($name[1]);
$lastname = $name[1];
}
$uname_suffix = $branch . substr($year, -2);
if ($lastname) {
$username = $name[0] . '.' . $lastname . '@';
} else {
$username = $name[0] . '@';
}
$temp = 1;
$tempusername = $username;
while ($this->uniqueuser($tempusername . $uname_suffix)) {
$tempusername = $username . $temp;
//.........这里部分代码省略.........
示例11: run
public function run()
{
$branch = new Branch();
$branch->name = 'Head Office';
$branch->save();
$currency = new Currency();
$currency->name = 'Kenyan Shillings';
$currency->shortname = 'KES';
$currency->save();
$organization = new Organization();
$organization->name = 'Lixnet Technologies';
$organization->save();
$share = new Share();
$share->value = 0;
$share->transfer_charge = 0;
$share->charged_on = 'donor';
$share->save();
$perm = new Permission();
$perm->name = 'create_employee';
$perm->display_name = 'Create employee';
$perm->category = 'Employee';
$perm->save();
$perm = new Permission();
$perm->name = 'update_employee';
$perm->display_name = 'Update employee';
$perm->category = 'Employee';
$perm->save();
$perm = new Permission();
$perm->name = 'delete_employee';
$perm->display_name = 'Deactivate employee';
$perm->category = 'Employee';
$perm->save();
$perm = new Permission();
$perm->name = 'view_employee';
$perm->display_name = 'View employee';
$perm->category = 'Employee';
$perm->save();
$perm = new Permission();
$perm->name = 'manage_earning';
$perm->display_name = 'Manage earnings';
$perm->category = 'Payroll';
$perm->save();
$perm = new Permission();
$perm->name = 'manage_deduction';
$perm->display_name = 'Manage deductions';
$perm->category = 'Payroll';
$perm->save();
$perm = new Permission();
$perm->name = 'manage_allowance';
$perm->display_name = 'Manage allowance';
$perm->category = 'Payroll';
$perm->save();
$perm = new Permission();
$perm->name = 'manage_relief';
$perm->display_name = 'Manage releif';
$perm->category = 'Payroll';
$perm->save();
$perm = new Permission();
$perm->name = 'manage_benefit';
$perm->display_name = 'Manage benefits';
$perm->category = 'Payroll';
$perm->save();
$perm = new Permission();
$perm->name = 'process_payroll';
$perm->display_name = 'Process payroll';
$perm->category = 'Payroll';
$perm->save();
$perm = new Permission();
$perm->name = 'view_payroll_report';
$perm->display_name = 'View reports';
$perm->category = 'Payroll';
$perm->save();
$perm = new Permission();
$perm->name = 'manage_settings';
$perm->display_name = 'Manage settings';
$perm->category = 'Payroll';
$perm->save();
$perm = new Permission();
$perm->name = 'view_application';
$perm->display_name = 'View applications';
$perm->category = 'Leave';
$perm->save();
$perm = new Permission();
$perm->name = 'amend_application';
$perm->display_name = 'Amend applications';
$perm->category = 'Leave';
$perm->save();
$perm = new Permission();
$perm->name = 'approve_application';
$perm->display_name = 'Approve applications';
$perm->category = 'Leave';
$perm->save();
$perm = new Permission();
$perm->name = 'reject_application';
$perm->display_name = 'Reject applications';
$perm->category = 'Leave';
$perm->save();
$perm = new Permission();
$perm->name = 'cancel_application';
$perm->display_name = 'Cancel applications';
//.........这里部分代码省略.........
示例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->aBranch !== null) {
if ($this->aBranch->isModified() || $this->aBranch->isNew()) {
$affectedRows += $this->aBranch->save($con);
}
$this->setBranch($this->aBranch);
}
if ($this->asfGuardUser !== null) {
if ($this->asfGuardUser->isModified() || $this->asfGuardUser->isNew()) {
$affectedRows += $this->asfGuardUser->save($con);
}
$this->setsfGuardUser($this->asfGuardUser);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
if ($this->commentsScheduledForDeletion !== null) {
if (!$this->commentsScheduledForDeletion->isEmpty()) {
CommentQuery::create()->filterByPrimaryKeys($this->commentsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
$this->commentsScheduledForDeletion = null;
}
}
if ($this->collComments !== null) {
foreach ($this->collComments as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->statusActionsScheduledForDeletion !== null) {
if (!$this->statusActionsScheduledForDeletion->isEmpty()) {
StatusActionQuery::create()->filterByPrimaryKeys($this->statusActionsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
$this->statusActionsScheduledForDeletion = null;
}
}
if ($this->collStatusActions !== null) {
foreach ($this->collStatusActions as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例13: save
function save()
{
$this->filter_access('Branch', 'roled_add', 'branches/index');
$branch = new Branch();
$branch->branch_name = $this->input->post('branch_name');
if ($branch->save()) {
$this->session->set_flashdata('message', 'Branch successfully created!');
redirect('branches/');
} else {
// Failed
$branch->error_message('custom', 'Branch Name required');
$msg = $branch->error->custom;
$this->session->set_flashdata('message', $msg);
redirect('branches/add');
}
}