本文整理汇总了PHP中People::save方法的典型用法代码示例。如果您正苦于以下问题:PHP People::save方法的具体用法?PHP People::save怎么用?PHP People::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类People
的用法示例。
在下文中一共展示了People::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new People();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['People'])) {
$model->attributes = $_POST['People'];
if ($model->save()) {
$model->mid = $model->get_mid();
$model->save();
$this->redirect(array('view', 'id' => $model->id));
}
}
$ac = People::getAutoCompleteFields();
$this->render('create', array('model' => $model, 'ac' => $ac));
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
$name = $request->input("name");
$age = $request->input("age");
$people = new People();
$people->name = $name;
$people->age = $age;
$people->save();
return "name={{$name}}, age={{$age}}";
}
示例3: actionCreate
/**
* 把一个用户任命为人员页面和处理方法
* @param integer $uid 用户ID
*/
public function actionCreate()
{
$model = new People();
$model->categorys = Category::model()->findAll(array('condition' => 'type="teacher"', 'order' => 'weight ASC'));
if (isset($_POST['People'])) {
$model->checkUser();
$model->attributes = $_POST['People'];
if ($model->save()) {
Yii::app()->user->setFlash('success', '操作成功');
$this->redirect(array('uploadFace', 'id' => $model->id));
} else {
Yii::app()->user->setFlash('error', '操作失败');
}
}
$this->render('create', array('model' => $model));
}
示例4: registerAction
public function registerAction()
{
echo "RegStart";
$user = new People();
//Store and check for errors
$success = $user->save($this->request->getPost(), array('name', 'email'));
if ($success) {
echo "Thanks for registering!";
} else {
echo "Sorry, the following problems were generated: ";
foreach ($user->getMessages() as $message) {
echo $message->getMessage(), "<br/>";
}
}
$this->view->disable();
}
示例5: actionTogglePeople
/**
* 设置、取消用户的实验室成员身份
* @param unknown $id
*/
public function actionTogglePeople($id)
{
$user = $this->loadModel($id);
$people = $user->people;
if ($people) {
if ($people->delete()) {
Yii::app()->user->setFlash('success', '已将用户移除实验室成员!');
}
} else {
$people = new People();
$people->name = $user->name;
$people->userId = $user->id;
$people->email = $user->email;
if ($people->save()) {
Yii::app()->user->setFlash('success', '已将用户设为实验室成员!');
}
}
$this->redirect(array('admin'));
}
示例6: actionDependents
public function actionDependents($id)
{
$model = $this->loadModel($id);
if (isset($_POST['People']['dependent'])) {
for ($i = 0; $i < 10; ++$i) {
if (isset($_POST['People']['dependent'][$i])) {
if ($pid = $_POST['People']['dependent'][$i]['id']) {
$p = People::model()->findByPk($pid);
} else {
$p = new People();
}
$p->attributes = $_POST['People']['dependent'][$i];
$p->family_id = $model->id;
$p->role = 'dependent';
$p->save();
}
}
}
$ppl_ac = People::getAutoCompleteFields();
$this->render('dependents', array('model' => $model, 'ppl_ac' => $ppl_ac));
}
示例7: array
<?php
require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/People.php";
session_start();
if (empty($_SESSION['address_book'])) {
$_SESSION['address_book'] = array();
}
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
return $app['twig']->render('address_book.html.twig', array('people' => People::getAll()));
});
$app->post("/people", function () use($app) {
$person = new People($_POST['name'], $_POST['phone_number'], $_POST['address']);
$person->save();
return $app['twig']->render('add_contact.html.twig', array('newperson' => $person));
});
$app->post("/delete_all", function () use($app) {
People::deleteAll();
return $app['twig']->render('delete_all.html.twig');
});
return $app;