本文整理汇总了PHP中Country::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::save方法的具体用法?PHP Country::save怎么用?PHP Country::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createCountry
public function createCountry($name)
{
$tmp = new Country();
$tmp->name = $name;
$tmp->save();
return $tmp;
}
示例2: postCountry
public function postCountry()
{
$posted = Input::get();
$country = new Country();
$country->country_name = $posted['country_name'];
$country->category_id = $posted['category_id'];
$country->category_name = $posted['category_name'];
$country->save();
return Redirect::back()->with('success', 'Country has been created');
}
示例3: newcountry
function newcountry($data)
{
if ($data['name']) {
$newcountry = new Country();
$newcountry->name = sqlite_escape_string($data['name']);
$newcountry->save();
return true;
} else {
return false;
}
}
示例4: actionCreate
public function actionCreate()
{
$model = new Country();
if (isset($_POST['Country'])) {
$model->attributes = $_POST['Country'];
if ($model->validate() && $model->save()) {
$this->redirect(array('index'));
}
}
$statusOptions = array(0 => Yii::t('common', 'Disabled'), 1 => Yii::t('common', 'Enabled'));
$yesNoOptions = array(0 => Yii::t('common', 'No'), 1 => Yii::t('common', 'Yes'));
$this->render('create', array('model' => $model, 'statusOptions' => $statusOptions, 'yesNoOptions' => $yesNoOptions));
}
示例5: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Country();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Country'])) {
$model->attributes = $_POST['Country'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例6: add_check
/**
* Add Country check
*/
public function add_check()
{
$validator = Validator::make(Input::all(), Country::$rulesAdd);
if (!$validator->fails()) {
$country = new Country(Input::all());
if ($country->save()) {
return Redirect::route('country_list', $country->id)->with('mSuccess', 'Le pays a bien été modifié');
} else {
return Redirect::route('country_add')->with('mError', 'Impossible de créer ce pays')->withInput();
}
} else {
return Redirect::route('country_add')->with('mError', 'Il y a des erreurs')->withErrors($validator->messages())->withInput();
}
}
示例7: postCountryCreate
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function postCountryCreate()
{
// Declare the rules for the form validation
$rules = array('country' => 'required');
// Validate the inputs
$validator = Validator::make(Input::all(), $rules);
// Check if the form validates with success
if ($validator->passes()) {
// Get the inputs, with some exceptions
$inputs = Input::except('csrf_token');
$this->country->country = $inputs['country'];
$this->country->save();
// Was the role created?
if ($this->country->id) {
// Redirect to the new role page
return Redirect::to('admin/countries/' . $this->country->id . '/edit')->with('success', Lang::get('admin/countries/messages.create.success'));
}
// Redirect to the new country page
return Redirect::to('admin/countries/create')->with('error', Lang::get('admin/countries/messages.create.error'));
}
// Form validation failed
return Redirect::to('admin/countries/create')->withInput()->withErrors($validator);
}
示例8: check
public static function check($_cpt, $_shrt)
{
$country = Country::model()->find('short=:shrt', array(':shrt' => $_shrt));
if ($country !== null) {
return $country->getPrimaryKey();
}
$country = new Country();
$country->attributes = array('caption' => $_cpt, 'short' => $_shrt);
if ($country->save()) {
return $country->getPrimaryKey();
}
return 1;
//false;
}
示例9: 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->aCountry !== null) {
if ($this->aCountry->isModified() || $this->aCountry->isNew()) {
$affectedRows += $this->aCountry->save($con);
}
$this->setCountry($this->aCountry);
}
if ($this->aCurrency !== null) {
if ($this->aCurrency->isModified() || $this->aCurrency->isNew()) {
$affectedRows += $this->aCurrency->save($con);
}
$this->setCurrency($this->aCurrency);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
if ($this->googleshoppingProductSynchronisationsScheduledForDeletion !== null) {
if (!$this->googleshoppingProductSynchronisationsScheduledForDeletion->isEmpty()) {
\GoogleShopping\Model\GoogleshoppingProductSynchronisationQuery::create()->filterByPrimaryKeys($this->googleshoppingProductSynchronisationsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
$this->googleshoppingProductSynchronisationsScheduledForDeletion = null;
}
}
if ($this->collGoogleshoppingProductSynchronisations !== null) {
foreach ($this->collGoogleshoppingProductSynchronisations as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例10: actionCreateOrg
public function actionCreateOrg()
{
$org = Organization::model()->count();
if ($org == 0) {
$this->layout = 'installation_layout';
$model = new Organization();
$user = new User();
$auth_assign = new AuthAssignment();
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
if (isset($_POST['Organization']['organization_name']) && !empty($_POST['Organization']['phone']) && !empty($_POST['Organization']['email'])) {
$country_model = new Country();
$country_model->name = $_POST['Organization']['country'];
$country_model->save();
$state_model = new State();
$state_model->state_name = $_POST['Organization']['state'];
$state_model->country_id = $country_model->id;
$state_model->save();
$city_model = new City();
$city_model->city_name = $_POST['Organization']['city'];
$city_model->country_id = $country_model->id;
$city_model->state_id = $state_model->state_id;
$city_model->save();
$model->attributes = $_POST['Organization'];
$model->organization_created_by = 1;
$model->organization_creation_date = new CDbExpression('NOW()');
$model->city = $city_model->city_id;
$model->state = $state_model->state_id;
$model->country = $country_model->id;
if ($model->save(false)) {
$user->user_organization_email_id = $model->email;
$user->user_password = md5($model->email . $model->email);
$user->user_type = 'admin';
$user->user_created_by = 1;
$user->user_creation_date = new CDbExpression('NOW()');
$user->user_organization_id = $model->organization_id;
$user->save();
$auth_assign->itemname = 'SuperAdmin';
$auth_assign->userid = $user->user_id;
$auth_assign->save(false);
$this->redirect(array('redirectLogin'));
}
}
$this->render('create_org', array('model' => $model));
} else {
Yii::app()->user->logout();
$this->redirect(array('login'));
}
}
示例11: actionCreate
public function actionCreate()
{
$model = new Country();
if (isset($_POST['Country'])) {
$model->setAttributes($_POST['Country']);
if ($model->save()) {
if (Yii::app()->getRequest()->getIsAjaxRequest()) {
Yii::app()->end();
} else {
$this->redirect(array('view', 'id' => $model->country_id));
}
}
}
$this->render('create', array('model' => $model));
}
示例12: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Country();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Country'])) {
$model->attributes = $_POST['Country'];
$model->created_on = date('Y-m-d');
$model->created_by = Yii::app()->user->id;
if ($model->save()) {
Yii::app()->user->setFlash('success', 'Saved successfully');
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例13: agregar
public function agregar()
{
$data = array();
if ($_POST) {
$pais = new Country(elements(array('pais'), $_POST));
if ($pais->is_valid()) {
$pais->save();
$this->session->set_flashdata('msg', '<div class="success">El pais se guardó correctamente.</div>');
redirect('paises');
} else {
$data['errors'] = $pais->errors;
}
}
$data['titulo'] = "Agregar pais";
$data['action'] = "paises/agregar";
$this->template->write_view('content', 'paises/agregar', $data);
$this->template->render();
}
示例14: save
public function save($id = null)
{
if ($this->perm->can_create == 'y') {
if ($_POST) {
$save = new Country();
if ($_POST['id'] == '') {
$_POST['created_by'] = $this->user->id;
} else {
$_POST['updated_by'] = $this->user->id;
}
$save->from_array($_POST);
$save->save();
$action = $_POST['id'] > 0 ? 'UPDATE' : 'CREATE';
save_logs($this->menu_id, $action, $save->id, $action . ' ' . $save->country_name . ' Country');
}
}
redirect("admin/" . $this->modules_name);
}
示例15: actionCreate
/**
* Add a new country
*/
public function actionCreate()
{
// Check Access
checkAccessThrowException('op_country_addpages');
$model = new Country();
if (isset($_POST['Country'])) {
$model->attributes = $_POST['Country'];
if ($model->save()) {
fok(at('Country Created.'));
alog(at("Created Country Record '{name}'.", array('{name}' => $model->name)));
$this->redirect(array('country/index'));
}
}
// Add Breadcrumb
$this->addBreadCrumb(at('Creating New Country'));
$this->title[] = at('Creating New Country Record');
// Display form
$this->render('form', array('model' => $model));
}