本文整理汇总了PHP中Place::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Place::save方法的具体用法?PHP Place::save怎么用?PHP Place::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Place
的用法示例。
在下文中一共展示了Place::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAddPlace
public function actionAddPlace()
{
$model = new Place();
$imageList = $this->_gets->getPost('imageList');
$imageListSerialize = XUtils::imageListSerialize($imageList);
if (isset($_POST['Place'])) {
$model->attributes = $_POST['Place'];
$model->host_id = $this->_user['hostId'];
$model->pic_other = $imageListSerialize['dataSerialize'];
$file = XUpload::upload($_FILES['attach']);
$adr = XUpload::upload($_FILES['pic_adr']);
if (is_array($file)) {
$model->pic = $file['pathname'];
@unlink($_POST['oAttach']);
@unlink($_POST['oThumb']);
}
// if ($model->pic == null){
// Yii::app()->user->setFlash('picMessage','主页图不能为空');
// }
if (is_array($adr)) {
$model->pic_adr = $adr['pathname'];
@unlink($_POST['oAttach']);
@unlink($_POST['oThumb']);
}
if ($model->pic_adr == null) {
Yii::app()->user->setFlash('picAdrMessage', '主图不能为空');
}
if ($model->validate() && $model->save()) {
$this->redirect(array('/host/default/myplace'));
}
}
$this->render('addplace', array('model' => $model, 'imageList' => $imageListSerialize['data']));
}
示例2: add_lugar
public function add_lugar()
{
$inputs = Input::all();
$rules = array('lugar_nombre' => 'required|max:50:lugar,lugar_nombre', 'lugar_codigo_postal' => 'integer:lugar,lugar_codigo_postal');
$validator = Validator::make($inputs, $rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator);
} else {
$lugar = new Place();
$lugar->lugar_nombre = Input::get('lugar_nombre');
if (Input::get('lugar_codigo_postal')) {
$lugar->lugar_codigo_postal = Input::get('lugar_codigo_postal');
} else {
$lugar->lugar_codigo_postal = NULL;
}
if (Input::get('fk_lugar') != 'NULL') {
$lugar->fk_lugar = Input::get('fk_lugar');
} else {
$lugar->fk_lugar = NULL;
}
$lugar->fk_lugar_tipo = Input::get('fk_lugar_tipo');
if ($lugar->save()) {
Session::flash('message', 'Guardado Correctamente');
Session::flash('class', 'success');
} else {
Session::flash('message', 'Ha ocurrido un error, intentelo nuevamente');
Session::flash('class', 'danger');
}
return Redirect::to('lugar');
}
}
示例3: actionAddPlace
public function actionAddPlace()
{
$model = new Place();
$imageList = $this->_gets->getPost('imageList');
$imageListSerialize = XUtils::imageListSerialize($imageList);
if (isset($_POST['Place'])) {
$model->attributes = $_POST['Place'];
$model->host_id = $this->_user['hostId'];
$model->pic_other = $imageListSerialize['dataSerialize'];
$file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(192, 470)));
$adr = XUpload::upload($_FILES['pic_adr'], array('thumb' => true, 'thumbSize' => array(498, 364)));
if (is_array($file)) {
$model->pic = $file['paththumbname'];
@unlink($_POST['oAttach']);
@unlink($_POST['oThumb']);
}
if (is_array($adr)) {
$model->pic_adr = $adr['paththumbname'];
@unlink($_POST['oAttach']);
@unlink($_POST['oThumb']);
}
if ($model->validate() && $model->save()) {
$this->redirect(array('/host/default/myplace'));
}
}
$this->render('addplace', array('model' => $model, 'imageList' => $imageListSerialize['data']));
}
示例4: morePlaces
public function morePlaces()
{
$places = json_decode(file_get_contents(storage_path() . '/demo-day.json'), true);
$pages = $places['query']['pages'];
foreach ($pages as $page) {
$place = new Place();
if (isset($page['coordinates'])) {
$coords = $page['coordinates'][0];
$place->latitude = $coords['lat'];
$place->longitude = $coords['lon'];
}
if (isset($page['thumbnail'])) {
$thumbnail = $page['thumbnail'];
$place->img_src = $thumbnail['source'];
$place->img_width = $thumbnail['width'];
$place->img_height = $thumbnail['height'];
}
if (isset($page['extract'])) {
$place->description = $page['extract'];
}
$place->title = $page['title'];
$place->pageid = $page['pageid'];
$place->link = "https://en.wikipedia.org/?curid={$place->pageid}";
$place->save();
}
}
示例5: actionCreate
/**
* Creates a new City model.
* If creation is successful, the browser will be redirected to the 'view' page.
*
* @return mixed
*/
public function actionCreate($regionId)
{
$region = $this->findRegion($regionId);
$model = new Place(['region_id' => $region->id]);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例6: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'update' page.
*/
public function actionCreate()
{
$model = new Place();
$placeInfo = Place::model()->findAll('createdByUserId=' . Yii::app()->user->getId() . ' AND title is NULL');
if (count($placeInfo) > 0) {
foreach ($placeInfo as $place) {
Place::model()->findByPk($place->id)->delete();
}
}
$model->save(false);
$this->redirect(array('update', 'id' => $model->id, 'newRecord' => true));
}
示例7: actionCreate
public function actionCreate()
{
$model = new Place();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Place'])) {
$model->attributes = $_POST['Place'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->place_id));
}
}
$this->render('create', array('model' => $model));
}
示例8: actionCreate
/**
* 录入
*
*/
public function actionCreate()
{
parent::_acl();
$model = new Place();
if (isset($_POST['Place'])) {
$acl = $this->_gets->getPost('acl');
$model->attributes = $_POST['Place'];
if ($model->save()) {
AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入内容,ID:' . $model->id));
$this->redirect(array('index'));
}
}
$this->render('placeRecommend_create', array('model' => $model));
}
示例9: array
<?php
require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Place.php";
session_start();
if (empty($_SESSION['list_of_places'])) {
$_SESSION['list_of_places'] = array();
}
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get('/', function () use($app) {
return $app['twig']->render('places.html.twig', array('places' => Place::getAll()));
});
$app->post("/places", function () use($app) {
$place = new Place($_POST['city']);
$place->save();
return $app['twig']->render('create_place.html.twig', array('newplace' => $task));
});
return $app;
示例10: Place
function test_verifyLocation()
{
$place_name2 = "Director Park";
$address2 = "SW Park Ave";
$longitude2 = 45.518672;
$latitude2 = -122.681211;
$id2 = 2;
$test_place = new Place($place_name2, $address2, $longitude2, $latitude2, $id2);
$test_place->save();
$user_name = "Nathan";
$password = "xxx60606";
$latitude = 45.518672;
$longitude = -122.681215;
$signed_in = 1;
$id = 1;
$test_user = new User($user_name, $password, $longitude, $latitude, $signed_in, $id);
$test_user->save();
$user_name2 = "John";
$password2 = "xxx";
$latitude2 = 45.518672;
$longitude2 = -122.681218;
$signed_in2 = 1;
$id2 = 1;
$test_user2 = new User($user_name2, $password2, $longitude2, $latitude2, $signed_in2, $id2);
$test_user2->save();
$var = $test_place->distanceFrom($test_user2);
var_dump($var);
$result = $test_place->verifyLocation($test_user, $test_user2);
$this->assertEquals(true, $result);
}
示例11: array
<?php
require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Place.php";
session_start();
if (empty($_SESSION['list_of_places'])) {
Place::deleteAll();
//start a new empty array
}
$app = new Silex\Application();
//Provide integration with the Twig templete engine
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
//root path
$app->get("/", function () use($app) {
return $app['twig']->render('places.html.twig', array('places' => Place::getAll()));
});
$app->post("/places", function () use($app) {
$place_and_time = new Place($_POST['place'], $_POST['time_stayed']);
$place_and_time->save();
return $app['twig']->render('create_places.html.twig', array('newplace' => $place_and_time));
});
$app->post("/delete_places", function () use($app) {
Place::deleteAll();
return $app['twig']->render('delete_places.html.twig');
});
return $app;
示例12: editClubEvent
/**
* Edit or create a clubevent with its entered information.
* If $id is null create a new clubEvent, otherwise the clubEvent specified by $id will be edit.
*
* @param int $id
* @return ClubEvent clubEvent
*/
private function editClubEvent($id)
{
$event = new ClubEvent();
if (!is_null($id)) {
$event = ClubEvent::findOrFail($id);
}
// format: strings; no validation needed
$event->evnt_title = Input::get('title');
$event->evnt_subtitle = Input::get('subtitle');
$event->evnt_public_info = Input::get('publicInfo');
$event->evnt_private_details = Input::get('privateDetails');
$event->evnt_type = Input::get('evnt_type');
// create new place
if (!Place::where('plc_title', '=', Input::get('place'))->first()) {
$place = new Place();
$place->plc_title = Input::get('place');
$place->save();
$event->plc_id = $place->id;
} else {
$event->plc_id = Place::where('plc_title', '=', Input::get('place'))->first()->id;
}
// format: date; validate on filled value
if (!empty(Input::get('beginDate'))) {
$newBeginDate = new DateTime(Input::get('beginDate'), new DateTimeZone(Config::get('app.timezone')));
$event->evnt_date_start = $newBeginDate->format('Y-m-d');
} else {
$event->evnt_date_start = date('Y-m-d', mktime(0, 0, 0, 0, 0, 0));
}
if (!empty(Input::get('endDate'))) {
$newEndDate = new DateTime(Input::get('endDate'), new DateTimeZone(Config::get('app.timezone')));
$event->evnt_date_end = $newEndDate->format('Y-m-d');
} else {
$event->evnt_date_end = date('Y-m-d', mktime(0, 0, 0, 0, 0, 0));
}
// format: time; validate on filled value
if (!empty(Input::get('beginTime'))) {
$event->evnt_time_start = Input::get('beginTime');
} else {
$event->evnt_time_start = mktime(0, 0, 0);
}
if (!empty(Input::get('endTime'))) {
$event->evnt_time_end = Input::get('endTime');
} else {
$event->evnt_time_end = mktime(0, 0, 0);
}
// format: tinyInt; validate on filled value
// reversed this: input=1 means "event is public", input=0 means "event is private"
$event->evnt_is_private = Input::get('isPrivate') == '1' ? 0 : 1;
return $event;
}
示例13: addSpouse
public static function addSpouse($spouse, $individualId, $spouseId)
{
$newSpouse = new Spouse();
$newSpouse->personId = $individualId;
$newSpouse->spouse = $spouseId;
$newSpouse->day = $spouse->marriageDate->day;
$newSpouse->month = $spouse->marriageDate->month;
$newSpouse->year = $spouse->marriageDate->year;
$newSpouse->yearM = $spouse->marriageDate->yearM;
$spouseId = $newSpouse->save();
if ($spouseId) {
$newSpouse->id = $spouseId;
$marriagePlace = new Place();
if ($spouse->marriagePlace && isset($spouse->marriagePlace->town)) {
$marriagePlace->town = $spouse->marriagePlace->town;
}
if ($spouse->marriagePlace && isset($spouse->marriagePlace->county)) {
$marriagePlace->county = $spouse->marriagePlace->county;
}
if ($spouse->marriagePlace && isset($spouse->marriagePlace->state)) {
$marriagePlace->state = $spouse->marriagePlace->state;
}
if ($spouse->marriagePlace && isset($spouse->marriagePlace->country)) {
$marriagePlace->country = $spouse->marriagePlace->country;
}
if ($spouse->marriagePlace && isset($spouse->marriagePlace->cemetary)) {
$marriagePlace->cemetary = $spouse->marriagePlace->cemetary;
}
$marriagePlace->ft_name = 'spouse';
$marriagePlace->fkey = $spouseId;
$marriageId = $marriagePlace->save();
if ($marriageId) {
$newSpouse->place = $marriageId;
$newSpouse->save();
}
}
return $newSpouse->id;
}
示例14: array
session_start();
if (empty($_SESSION['list_of_cities'])) {
$_SESSION['list_of_cities'] = array();
}
$app = new Silex\Application();
//Twig Path
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
//Route and Controller
$app->get("/", function () use($app) {
$all_cities = Place::getAll();
return $app['twig']->render('city.html.twig', array('cities' => $all_cities));
});
/* $app->get("/", function() use ($app) {
$all_times = Place::getAll();
return $app['twig']->render('city.html.twig', array('times' => $all_times));
}); */
//cities POST
$app->post("/city", function () use($app) {
$city = new Place($_POST['cityName'], $_POST['lengthOfTime'], $_POST['reasonOfVisit'], $_POST['imagePath']);
$city->save();
return $app['twig']->render('create_city.html.twig', array('newcity' => $city));
});
//cities POST delete
$app->post("/delete_city", function () use($app) {
Place::deleteAll();
return $app['twig']->render('delete_city.html.twig');
});
return $app;
示例15: array
<?php
require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Place.php";
session_start();
if (empty($_SESSION['list_of_places'])) {
$_SESSION['list_of_places'] = array();
}
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
return $app['twig']->render('places.html.twig', array('places' => Place::getAll()));
});
$app->post("/places", function () use($app) {
$new_city = new Place($_POST['city'], $_POST['photo'], $_POST['landmark'], $_POST['date']);
$new_city->save();
return $app['twig']->render('create_place.html.twig', array('newPlace' => $new_city));
});
$app->post("/delete_places", function () use($app) {
Place::deleteAll();
return $app['twig']->render('delete_places.html.twig');
});
return $app;