本文整理汇总了PHP中Student::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::save方法的具体用法?PHP Student::save怎么用?PHP Student::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Student
的用法示例。
在下文中一共展示了Student::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
/**
* Authenticates a dummy user.
* @return boolean always true.
*/
public function authenticate()
{
$student = Student::model()->findByAttributes(array('username' => $this->username));
if ($student === null) {
$student = new Student();
$faculty = Faculty::model()->findByPk(1);
if ($faculty === null) {
$faculty = new Faculty();
$faculty->id = 1;
$faculty->name = 'Dummy Faculty';
$faculty->save(false);
}
$student->username = $this->username;
$student->name = $this->name;
$student->is_admin = $this->isAdmin;
$student->faculty_id = $faculty->id;
$student->photo = Yii::app()->params['defaultProfilePhoto'];
}
$student->last_login_timestamp = date('Y-m-d H:i:s');
$student->save();
$this->id = $student->id;
$this->name = $student->name;
$this->setState('isAdmin', $student->is_admin);
$this->setState('profilePhoto', $student->photo);
return true;
}
示例2: add
function add()
{
$model = new Student();
// var_dump($_POST);exit;
if (isset($_POST['student']) and $_POST['student']['first_name'] != '' and $_POST['student']['last_name'] != '' and $_POST['student']['f_number'] != '') {
$student = $_POST['student'];
$first_name = $student['first_name'];
$last_name = $student['last_name'];
$f_number = $student['f_number'];
$group = $student['group'];
$flow = $student['flow'];
$alumni = $student['alumni'];
$subject = $student['subject'];
$model->first_name = $first_name;
$model->last_name = $last_name;
$model->f_number = $f_number;
$model->group = $group;
$model->flow = $flow;
$model->alumni = $alumni;
$model->subject = $subject;
if ($model->save()) {
header('Location: ' . 'index.php?url=students/index');
die;
}
} else {
$this->set("title", "Empty field! Add failed!");
}
}
示例3: register
public function register()
{
$id = Input::get('stu_id');
$name = Input::get('stu_name');
$nick = Input::get('stu_nick');
$email = Input::get('stu_email');
if (Student::where("account", "=", $id)->count() > 0) {
$student = Student::where("account", "=", $id)->first();
$student->name = $name;
$student->nick = str_replace("root", "**", str_replace("admin", "*", str_replace("管理員", "***", $nick)));
$student->email = $email;
$student->account = $id;
$auth = $student->auth;
$student->save();
return $auth;
} else {
$student = new Student();
$student->name = $name;
$student->nick = str_replace("root", "**", str_replace("admin", "*", str_replace("管理員", "***", $nick)));
$student->email = $email;
$student->account = $id;
$auth = str_random(20);
while (true) {
if (Student::where("auth", "=", $auth)->count() == 0) {
$student->auth = $auth;
break;
} else {
$auth = str_random(20);
}
}
$student->save();
return $auth;
}
}
示例4: agregar
public function agregar()
{
$data = array();
if ($_POST) {
$this->load->helper('date');
$this->load->library('Utils');
$insert = $_POST;
$insert['fecha_nacimiento'] = $this->utils->fecha_formato('%Y-%m-%d', $insert['fecha_nacimiento']);
$insert['fecha_inscripcion'] = $this->utils->fecha_formato('%Y-%m-%d', $insert['fecha_inscripcion']);
$tutor = new Student(elements(array('city_id', 'nombre', 'apellido', 'fecha_nacimiento', 'sexo', 'tipo_documento', 'nro_documento', 'domicilio', 'tenencia', 'nacionalidad', 'grupo_sanguineo', 'telefono', 'celular', 'obs_medicas', 'observaciones', 'colegio_procedencia', 'fecha_inscripcion'), $insert));
if ($tutor->is_valid()) {
$tutor->save();
$this->session->set_flashdata('msg', '<div class="success">El tutor se guardó correctamente.</div>');
redirect('tutores/agregar');
} else {
$data['errors'] = $tutor->errors;
}
}
$data['paises'] = Country::all();
$data['provincias'] = State::all();
$data['ciudades'] = City::all();
$data['titulo'] = "Agregar tutor";
$data['action'] = "tutores/agregar";
$this->template->write_view('content', 'tutores/agregar', $data);
$this->template->render();
}
示例5: actionCreate
public function actionCreate()
{
$model = new User();
$model->scenario = 'create';
$this->performAjaxValidation($model);
$student = new Student();
$valid = true;
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$model->setRole = $_POST['User']['setRole'];
$valid = $valid && $model->validate();
}
if (isset($_POST['Student'])) {
$student->attributes = $_POST['Student'];
if ($_POST['User']['setRole'] == 3) {
$valid = $valid && $student->validate();
}
}
if (isset($_POST['User']) && $valid) {
$model->save();
$student->id_user = $model->id_user;
if (isset($_POST['Student']) && $_POST['User']['setRole'] == 3) {
$student->save();
}
$this->redirect(array('allusers'));
}
$this->render('create', array('model' => $model, 'student' => $student));
}
示例6: importData
public function importData()
{
$siswas = Siswa::all();
foreach ($siswas as $siswa) {
ini_set('max_execution_time', 300);
$student = new Student();
$student->name = $siswa->FullName;
if ($siswa->Sex == 'MALE') {
$student->sex = 'L';
$student->photo = 'boy.png';
} else {
$student->sex = 'P';
$student->photo = 'girl.png';
}
$student->birthplace = $siswa->BirthPlace;
$student->birthdate = $siswa->BirthDate;
$student->religion = $siswa->Religion;
$student->address = $siswa->FullAddress;
$student->contact = $siswa->CellPhone;
$student->father_name = $siswa->FatherName;
$student->father_occupation = $siswa->FatherOccupation;
$student->father_address = $siswa->FatherAddress;
$student->father_contact = $siswa->FatherContact;
$student->mother_name = $siswa->MotherName;
$student->mother_occupation = $siswa->MotherOccupation;
$student->mother_address = $siswa->MotherAddress;
$student->mother_contact = $siswa->MotherContact;
$student->save();
}
Session::flash('message', 'Sukses mengimport Data Siswa');
return Redirect::to('/');
}
示例7: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
$names = array('Martin', 'Pedro', 'Lucas', 'Agustin', 'Cristian', 'Matias', 'Tomas', 'Cludio', 'Nancy', 'Emilia', 'Alejandra', 'Barbara', 'Luciana', 'Lucia', 'Belen', 'Natalia', 'Adriana', 'Patricio', 'Diego', 'Gonzalo', 'Juan', 'Pablo');
$last_names = array('Ramirez', 'Rodriguez', 'Cordoba', 'Brown', 'Osorio', 'Diaz', 'Ayesa', 'Ramirez', 'Perez', 'Ripoll', 'Bottini', 'Ponce', 'Casella', 'Martinez', 'Erviti', 'Rodgriguez', 'Gonzalez', 'Fernandez', 'Benitez');
$this->createContextInstance('backend');
for ($i = 1; $i <= 100; $i++) {
$person = new Person();
$person->setLastname($last_names[rand(0, 18)]);
$person->setFirstName($names[rand(0, 21)]);
$person->setIdentificationType(1);
$person->setIdentificationNumber($i);
$person->setSex(rand(1, 2));
$person->setBirthDate('2000-06-30');
$student = new Student();
$student->setGlobalFileNumber($i);
$student->setPerson($person);
$person->save();
$student->save();
$this->logSection("Person created", $person->__toString());
}
// add your code here
}
示例8: save
public function save($data)
{
$student = new Student();
$student->first_name = $data['first_name'];
$student->last_name = $data['last_name'];
$student->dob = $data['dob'];
$student->irs_number = $data['irs_number'];
$student->save();
return $student;
}
示例9: executeNew
public function executeNew(sfWebRequest $request)
{
$programSectionId = $request->getParameter('sectionId');
$this->sectionDetail = Doctrine_Core::getTable('ProgramSection')->findOneById($programSectionId);
$this->forward404Unless($this->sectionDetail);
## New Form
$this->studentForm = new FrontendStudentForm();
if ($request->isMethod('POST')) {
$this->studentForm->bind($request->getParameter('studentform'));
if ($this->studentForm->isValid()) {
$formData = $this->studentForm->getValues();
$student = new Student();
$name = $formData['name'];
$fathersName = $formData['fathers_name'];
$grandfathersName = $formData['grandfathers_name'];
$motherName = $formData['mother_name'];
$dateOfBirth = $formData['date_of_birth'];
$sex = $formData['sex'];
$nationality = $formData['nationality'];
$birthLocation = $formData['birth_location'];
$residenceCity = $formData['residence_city'];
$residenceWoreda = $formData['residence_woreda'];
$residenceKebele = $formData['residence_kebele'];
$residenceHourseNumber = $formData['residence_house_number'];
$ethnicity = $formData['ethnicity'];
$telephone = $formData['telephone'];
$email = $formData['email'];
$student->setName($name);
$student->setFathersName($fathersName);
$student->setGrandfathersName($grandfathersName);
$student->setMotherName($motherName);
$student->setDateOfBirth($dateOfBirth);
$student->setSex($sex);
$student->setAdmissionYear(date('Y'));
$student->setNationality($nationality);
$student->setBirthLocation($birthLocation);
$student->setResidenceCity($residenceCity);
$student->setResidenceWoreda($residenceWoreda);
$student->setResidenceKebele($residenceKebele);
$student->setResidenceHouseNumber($residenceHourseNumber);
$student->setEthinicity($ethnicity);
$student->setTelephone($telephone);
$student->setEmail($email);
$student->save();
$enrollment = new EnrollmentInfo();
$enrollment->makeEnrollment(null, null, null, null, $programSectionId, sfConfig::get('app_transfer_enrollment'), $student->getId());
$auditlog = new AuditLog();
$auditlog->addNewLogInfo($this->getUser()->getAttribute('userId'), 'Performed Enrollment of Transfered Student');
$this->getUser()->setFlash('notice', 'Transfer Enrollment Was Successful ');
$this->redirect('transfer/sectiondetail/?id=' . $programSectionId);
} else {
$this->getUser()->setFlash('error', 'Error with Transfer Enrollment Form');
}
}
}
示例10: validate
protected function validate()
{
$required = array("teacher_id" => "Teacher Id", "admission_date" => "Admission Date", "name" => "Name", "subject_id" => "Subject", "date_of_birth" => "Date of Birth", "gender" => "Gender", "mobile" => "Mobile");
global $user;
if ($user->checkAdmin() == true) {
if (isset($_POST)) {
foreach ($required as $key => $value) {
if (!isset($_POST[$key]) || $_POST[$key] == '' || $_POST[$key] == 'select') {
echo $value . ' is Required<br/>';
return;
}
}
if (!is_numeric($_POST['mobile'])) {
echo "Mobile number must be Numeric";
} else {
if (isset($_POST['permanent_pincode']) && $_POST['permanent_pincode'] != '' && !is_numeric($_POST['permanent_pincode']) || isset($_POST['correspondence_pincode']) && $_POST['correspondence_pincode'] != '' && !is_numeric($_POST['correspondence_pincode'])) {
echo "Pincode must be Numeric";
} else {
echo 'Saving...';
global $objPDO;
require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/student_class.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/student_profile_class.php';
$teacher = new Student($objPDO);
$teacherProfile = new Teacher($objPDO);
$temp_pass = substr(md5(microtime()), 5, 10);
$pass = md5($temp_pass);
$teacher_id = $_POST['teacher_id'];
if ($_POST['blood_group'] == 'select') {
unset($_POST['blood_group']);
}
$acct_type = 'teacher';
$teacher->setacctType($acct_type);
$teacher->loadByRoll($teacher_id);
$teacher->setRollNo($teacher_id);
$teacher->setPhone($_POST['phone']);
$teacher->setName($_POST['name']);
$teacher->setEmail($_POST['email']);
if ($teacher->getPassword() == '' || $teacher->getPassword() == NULL) {
$teacher->setPassword($pass);
}
$teacher->save();
$id = $teacher->getID();
$teacherProfile->setByArray($_POST);
$teacherProfile->setTempPass($temp_pass);
$teacherProfile->setUserId($id);
$teacherProfile->save();
echo '<meta http-equiv="Refresh" content="0;url=http://localhost/cloud/teacher/confirm/' . $teacherProfile->getUserId() . '"/>';
}
}
}
} else {
header('Location:http://localhost/cloud');
}
}
示例11: Student
function test_save()
{
//Arrange
$name = "Joleen";
$enrollment = "2015-09-18";
$test_student = new Student($name, $enrollment);
$test_student->save();
//Act
$result = Student::getAll();
//Assert
$this->assertEquals($test_student, $result[0]);
}
示例12: actionRegister
public function actionRegister()
{
$model = new Student();
if (isset($_POST['Student'])) {
$model->attributes = $_POST['Student'];
if ($model->save()) {
echo '提交成功,等待管理员确认';
die;
}
}
$this->render('register', array('model' => $model));
}
示例13: testSave
function testSave()
{
//Arrange
$student_name = "Johnny Mcfly";
$date_enrollment = "12-12-2012";
$test_student = new Student($student_name, $date_enrollment);
//Act
$test_student->save();
//Assert
$result = Student::getAll();
$this->assertEquals($test_student, $result[0]);
}
示例14: testSave
function testSave()
{
//Arrange
$student_name = "Mike Laser";
$date_enrollment = "2014-08-15";
$id = 3;
$test_student = new Student($student_name, $date_enrollment, $id);
//Act
$test_student->save();
//Assert
$result = Student::getAll();
$this->assertEquals($test_student, $result[0]);
}
示例15: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Student();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Student'])) {
$model->attributes = $_POST['Student'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->student_id));
}
}
$this->render('create', array('model' => $model));
}