本文整理汇总了PHP中Area::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Area::save方法的具体用法?PHP Area::save怎么用?PHP Area::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Area
的用法示例。
在下文中一共展示了Area::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit_create_area
public function submit_create_area()
{
if (Auth::check()) {
$data["inside_url"] = Config::get('app.inside_url');
$data["user"] = Session::get('user');
// Verifico si el usuario es un Webmaster
if ($data["user"]->idrol == 1) {
// Validate the info, create rules for the inputs
$attributes = array('nombre_area' => 'Nombre del Área', 'descripción_area' => 'Descripción del Área', 'tipo_area' => 'Tipo del Área');
$messages = array();
$rules = array('nombre_area' => 'required|max:100|unique:areas,nombre|alpha_spaces', 'descripcion_area' => 'max:200|alpha_spaces', 'tipo_area' => 'required');
// Run the validation rules on the inputs from the form
$validator = Validator::make(Input::all(), $rules, $messages, $attributes);
// If the validator fails, redirect back to the form
if ($validator->fails()) {
return Redirect::to('areas/create_area')->withErrors($validator)->withInput(Input::all());
} else {
$area = new Area();
$area->nombre = Input::get('nombre_area');
$area->descripcion = Input::get('descripcion_area');
$area->idtipo_area = Input::get('tipo_area');
$area->idestado = 1;
$area->save();
return Redirect::to('areas/list_areas')->with('message', 'Se registró correctamente el área: ' . $area->nombre);
}
} else {
return View::make('error/error', $data);
}
} else {
return View::make('error/error', $data);
}
}
示例2: 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 ConnectionInterface $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(ConnectionInterface $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->aArea !== null) {
if ($this->aArea->isModified() || $this->aArea->isNew()) {
$affectedRows += $this->aArea->save($con);
}
$this->setArea($this->aArea);
}
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;
}
示例3: store
/**
* Store a newly created resource in storage.
* POST /areas
*
* @return Response
*/
public function store()
{
$area = new Area();
$area->title = Input::get('title');
if ($area->save()) {
return Redirect::to('allAreas');
}
return Redirect::to('createArea');
}
示例4: actionCreate
/**
* Creates a new model.
*/
public function actionCreate()
{
$model = new Area();
if (isset($_POST['Area'])) {
$model->attributes = $_POST['Area'];
if ($model->save()) {
$this->redirect(array('index'));
}
}
$this->render('create', array('model' => $model));
}
示例5: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Area();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Area'])) {
$model->attributes = $_POST['Area'];
if ($model->save()) {
$this->redirect(array('admin'));
}
}
$this->render('create', array('model' => $model));
}
示例6: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Area();
if (isset($_POST['Area'])) {
$model->attributes = $_POST['Area'];
$model->created_at = $this->getCurrentDateTime();
if ($model->save()) {
$this->addMessage('Record created successfully.');
$this->redirect(array('index'));
}
}
$this->render('create', array('model' => $model, 'collectors' => User::getAllCollectors()));
}
示例7: post_areas
public static function post_areas($recibido)
{
$area = new Area();
$area->add_data($recibido);
$respuesta = new stdClass();
$respuesta->result = $area->save();
if ($respuesta->result) {
$respuesta->mensaje = "Área registrada correctamente.";
$respuesta->area = $area;
} else {
$respuesta->mensaje = "No se pudo registrar el área.";
}
return $respuesta;
}
示例8: store
/**
* Store a newly created resource in storage.
* POST /area
*
* @return Response
*/
public function store()
{
Input::merge(array_map('trim', Input::all()));
$input = Input::all();
$validation = Validator::make($input, Area::$rules);
if ($validation->passes()) {
$area = new Area();
$area->area_no = Input::get('area_number');
$area->area_place = strtoupper(Input::get('area_place'));
$area->save();
return Redirect::route('area.index')->with('class', 'success')->with('message', 'Record successfully created.');
} else {
return Redirect::route('area.create')->withInput()->withErrors($validation)->with('class', 'error')->with('message', 'There were validation errors.');
}
}
示例9: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($id)
{
$model = new Area();
$model->zone_id = $id;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Area'])) {
$model->attributes = $_POST['Area'];
if ($model->save()) {
UserLogs::createLog('create new ' . get_class($model) . ' ' . $model->primaryKey);
$this->redirect(array('zone/view', 'id' => $model->zone_id));
}
}
$this->render('create', array('model' => $model));
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
$rules = array("areaId" => "required", "areaName" => "required");
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('/area/create')->withErrors($validator);
}
//
$area = new Area();
$area->areaID = Input::get('areaId');
$area->areaName = Input::get('areaName');
$area->save();
return Redirect::to('/area');
}
示例11: store
/**
* Store a newly created resource in storage.
* POST /area
*
* @return Response
*/
public function store()
{
$V = Validator::make(Input::all(), ['name' => 'required|string']);
if ($V->fails()) {
return Response::json($V->messages()->all(), 400);
}
$name = Input::get('name');
$Area = Area::where('name', '=', $name);
if ($Area->count() > 0) {
// already exists :/
return Response::json($Area->toArray(), 409);
}
$NewArea = new Area();
$NewArea->name = $name;
$NewArea->save();
return Response::json($NewArea->toArray(), 201);
}
示例12: postCrear
/**
* Store a newly created resource in storage.
* POST /area/crear
*
* @return Response
*/
public function postCrear()
{
//si la peticion es ajax
if (Request::ajax()) {
// if (Input::get('txt_token') != Session::get('s_token')) {
// die('token no valido!! Token Input: '.Input::get('txt_token').' Token Session: '.Session::get('s_token'));
// } else {
$regex = 'regex:/^([a-zA-Z .,ñÑÁÉÍÓÚáéíóú]{2,60})$/i';
$required = 'required';
$reglas = array('nombre' => $required . '|' . $regex);
$mensaje = array('required' => ':attribute Es requerido', 'regex' => ':attribute Solo debe ser Texto');
$validator = Validator::make(Input::all(), $reglas, $mensaje);
if ($validator->fails()) {
return Response::json(array('rst' => 2, 'msj' => $validator->messages()));
}
$areas = new Area();
$areas->nombre = Input::get('nombre');
$areas->estado = Input::get('estado');
$areas->save();
return Response::json(array('rst' => 1, 'msj' => 'Registro realizado correctamente'));
// }
}
}
示例13: postAreaAdd
public function postAreaAdd()
{
$validator = Validator::make(Input::all(), Area::$rules);
if ($validator->fails()) {
return Redirect::to('branch/area-add')->withErrors($validator)->withInput();
}
$area = new Area();
$area->name = Input::get('name');
$area->code = Input::get('code');
$area->save();
return Redirect::to('branch/area')->with('success', '区域添加成功!');
}
示例14: migrarAreas
private function migrarAreas()
{
$this->info("Migrando areas");
$this->getTable('especialidad')->chunk(1000, function ($areas) {
foreach ($areas as $area) {
$this->info("Migrando area: " . $area->codespecialidad);
$areaNueva = new Area();
$areaNueva->desabilitarConcurrencia();
$areaNueva->desabilitarValidaciones();
$areaNueva->id = $area->codespecialidad;
$areaNueva->nombre = $area->nombespecialidad;
$areaNueva->descripcion = $area->descespecialidad;
$areaNueva->tipo_ayuda_id = 1;
$areaNueva->save();
}
});
}
示例15: getRows
public function getRows($pq)
{
$rows = $pq->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']");
$n = count($rows);
echo 'Jumlah propinsi: ' . $n . " \n";
$count = 0;
foreach ($rows as $value) {
$count++;
$row = pq($value);
$kolom_provinsi = $row->find('td:eq(1) > a');
$nama_provinsi = $kolom_provinsi->text();
$link_provinsi = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolom_provinsi->attr('href')) . '&perhal=1000';
echo sprintf("Memproses propinsi %d dari %d\n", $count, $n);
echo sprintf("Propinsi: %s Link: %s\n", $nama_provinsi, $link_provinsi);
$province = Province::model()->findByAttributes(array('name' => $nama_provinsi));
if (!$province instanceof Province) {
$province = new Province();
$province->name = $nama_provinsi;
if (!$province->save()) {
throw new CException('Cannot save province');
}
}
$countdistrict = 0;
$pqDist = phpQuery::newDocumentHtml($this->getContents($link_provinsi));
$rowsDist = $pqDist->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']");
$nDist = count($rowsDist);
$countDist = 0;
foreach ($rowsDist as $valueDist) {
$countDist++;
$rowDist = pq($valueDist);
switch ($rowDist->find('td:eq(2)')->text()) {
case 'Kota':
$tipeDist = 'kota';
break;
default:
case 'Kab.':
$tipeDist = 'kabupaten';
break;
}
$kolomDist = $rowDist->find('td:eq(3) > a');
$namaDist = $kolomDist->text();
$linkDist = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolomDist->attr('href')) . '&perhal=1000';
echo sprintf("Memproses distrik " . $province->name . " %d dari %d\n", $countDist, $nDist);
echo sprintf("Distrik: %s Link: %s\n", $namaDist, $linkDist);
$distrik = District::model()->findByAttributes(array('name' => $namaDist, 'province_id' => $province->id, 'type' => $tipeDist));
if (!$distrik instanceof District) {
$distrik = new District();
$distrik->name = $namaDist;
$distrik->type = $tipeDist;
$distrik->province_id = $province->id;
if (!$distrik->save()) {
throw new CException('Cannot save district');
}
}
$pqZone = phpQuery::newDocumentHtml($this->getContents($linkDist));
$rowsZone = $pqZone->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']");
$nZone = count($rowsZone);
$countZone = 0;
foreach ($rowsZone as $valueZone) {
$countZone++;
$rowZone = pq($valueZone);
$kolomZone = $rowZone->find('td:eq(4) > a');
$namaZone = $kolomZone->text();
$linkZone = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolomZone->attr('href')) . '&perhal=1000';
echo sprintf("Memproses zone %d dari %d\n", $countZone, $nZone);
echo sprintf("zone: %s Link: %s\n", $namaZone, $linkZone);
$new_zone = false;
$zone = Zone::model()->findByAttributes(array('name' => $namaZone, 'district_id' => $distrik->id));
if (!$zone instanceof Zone) {
$zone = new Zone();
$zone->name = $namaZone;
$zone->active = 1;
$zone->district_id = $distrik->id;
if (!$zone->save()) {
throw new CException('Cannot save Zone');
}
$new_zone = true;
}
echo 'sukses saving zone' . "\n";
$countArea = 0;
$pqArea = phpQuery::newDocumentHtml($this->getContents($linkZone));
$rowsArea = $pqArea->find("table[bgcolor='#ffccff'] tr[bgcolor='#ccffff']");
$nArea = count($rowsArea);
// Let's speed up things a bit
$trans = Yii::app()->db->beginTransaction();
foreach ($rowsArea as $valueArea) {
$countArea++;
$rowArea = pq($valueArea);
$kolomArea = $rowArea->find('td:eq(2) > a');
$kolomKodePos = $rowArea->find('td:eq(1)');
$namaArea = $kolomArea->text();
$kodePos = $kolomKodePos->text();
$linkKodePos = str_replace(' ', '%20', self::NomorNetKodePosBaseUrl . $kolomArea->attr('href')) . '&perhal=1000';
$area = $new_zone ? null : Area::model()->findByAttributes(array('name' => $namaArea, 'zone_id' => $zone->id));
if (!$area instanceof Area) {
$area = new Area();
$area->name = $namaArea;
$area->postcode = $kodePos;
$area->zone_id = $zone->id;
if (!$area->save()) {
//.........这里部分代码省略.........