本文整理汇总了PHP中Students类的典型用法代码示例。如果您正苦于以下问题:PHP Students类的具体用法?PHP Students怎么用?PHP Students使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Students类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_by_id
public function get_by_id($id)
{
$student = null;
//database connect
$this->db->connect();
//query
$sql = "SELECT * FROM students WHERE id=?";
//execute
$stmt = $this->db->initStatement($sql);
$stmt->bind_param("i", $id);
$stmt->execute();
$stmt->bind_result($id, $first_name, $last_name, $email, $contact_no, $course);
while ($stmt->fetch()) {
//put in object
$student = new Students();
$student->set_id($id);
$student->get_id();
$student->set_first_name($first_name);
$student->set_last_name($last_name);
$student->set_email($email);
$student->set_contact_no($contact_no);
$student->set_course($course);
}
$this->db->close();
return $student;
}
示例2: __construct
function __construct()
{
$url = isset($_GET['url']) ? $_GET['url'] : null;
$url = rtrim($url, '/');
$url = explode('/', $url);
//print_r($url);
if ($url[0] == 'services') {
if (isset($url[2])) {
require 'services/' . $url[1] . '.php';
$controller = new Students();
$controller->selectById($url[2]);
return false;
} else {
if (isset($url[1])) {
require 'services/' . $url[1] . '.php';
$controller = new Students();
$controller->index();
return false;
}
}
} else {
if (empty($url[0])) {
require 'controllers/index.php';
$controller = new Index();
$controller->index();
return false;
}
$file = 'controllers/' . $url[0] . '.php';
if (file_exists($file)) {
require $file;
} else {
$this->error();
}
$controller = new $url[0]();
$controller->loadModel($url[0]);
if (isset($url[2])) {
if (method_exists($controller, $url[1])) {
$controller->{$url[1]}($url[2]);
} else {
$this->error();
}
} else {
if (isset($url[1])) {
if (method_exists($controller, $url[1])) {
$controller->{$url[1]}();
} else {
$this->error();
}
} else {
$controller->index();
}
}
}
}
示例3: create
public static function create()
{
if (!isset($student_instance)) {
self::$student_instance = new Students();
}
return self::$student_instance;
}
示例4: exportSelected
public function exportSelected()
{
$selected_students = Input::get('studentId');
if (is_array($selected_students)) {
//Setup CSV
$csv = \League\Csv\Writer::createFromFileObject(new \SplTempFileObject());
$column_flag = false;
$student = [];
foreach ($selected_students as $student_id) {
$student_data = Students::with('course')->find($student_id);
//Personal data
$student['firstname'] = $student_data['firstname'];
$student['surname'] = $student_data['surname'];
$student['email'] = $student_data['email'];
//Course data
$student['university'] = $student_data->course['university'];
$student['course_name'] = $student_data->course['course_name'];
//Check whether column headers have been set (not ideal for large datasets)
if ($column_flag === false) {
$csv->insertOne(\Schema::getColumnListing('student'));
$column_flag = true;
}
//Add student record to file
$csv->insertOne($student);
}
} else {
return "NO STUDENTS SELECTED";
}
//is_array($selected_students)
$csv->output("selected_student_records.csv");
}
示例5: save
/**
*
* Переобъявляем сохранение
*
**/
public function save()
{
$student = Students::model()->findByPk(Yii::app()->my->id);
$student->settings = json_encode($this->_attributes);
$student->save();
$_SESSION["settings"] = $student->settings;
}
示例6: actionView
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
if (isset($_POST['idProfile']) && isset($_POST['idEssay']) && isset($_POST['stardate']) && isset($_POST['enddate'])) {
if (!empty($_POST['idProfile']) && !empty($_POST['idEssay']) && !empty($_POST['stardate']) && !empty($_POST['enddate'])) {
$essay = $this->loadModel($id);
$model = new EssaysHasCrugeUser();
$idStudent = Students::model()->find('profile_id=' . $_POST['idProfile'])->id;
$model->status = 1;
$model->stardate = strtotime($_POST['stardate']);
$model->enddate = strtotime($_POST['enddate']);
$model->essays_id = $_POST['idEssay'];
$model->title_essay = $essay->getNameTitleEssay($idStudent, $essay->colleges_has_majors_colleges_id, $essay->type_essay_id, $_POST['idEssay']);
$model->students_id = $idStudent;
/* echo "<pre>";
echo print_r($model->enddate);
echo "</pre>";
Yii::app()->end(); */
if ($model->save()) {
Yii::app()->user->setFlash('save', 'El Estudiante se ha agregado correctamente.');
$this->redirect(array('view', 'id' => $model->essays_id));
}
}
Yii::app()->user->setFlash('error', 'Debe seleccionar un Estudiante, la fecha de inicio y culminación del Essay.');
$this->redirect(array('view', 'id' => $_POST['idEssay']));
}
$this->render('view', array('model' => $this->loadModel($id)));
}
示例7: studentname
public function studentname($data, $row)
{
$student = Students::model()->findByAttributes(array('id' => $data->student_id));
if ($student != NULL) {
return ucfirst($student->first_name) . ' ' . ucfirst($student->last_name);
} else {
return '-';
}
}
示例8: map_data
private function map_data()
{
$student = new Students();
$student->set_first_name($_POST['first_name']);
$student->set_last_name($_POST['last_name']);
$student->set_email($_POST['email']);
$student->set_contact_no($_POST['contact_no']);
$student->set_course($_POST['course_id']);
return $student;
}
示例9: _map_posted_data
private function _map_posted_data()
{
$students = new Students();
$students->set_first_name($_POST['first_name']);
$students->set_last_name($_POST['last_name']);
$students->set_email($_POST['email']);
$students->set_contact_no($_POST['contact_no']);
$students->set_course($_POST['course']);
return $students;
}
示例10: execute
private function execute($query)
{
$data = null;
$pdoData = Students::getPDO()->prepare($query);
$pdoData->execute();
$responseMassage = $pdoData->errorInfo();
//Объект с сообщением и кодом о проведеной операции
if ($responseMassage[0] == 0) {
//если выборка прошла то ....
$data = $pdoData;
}
return $data;
}
示例11: login
public static function login()
{
$input = Input::all();
$sid = Students::checkStudent($input['email'], $input['password']);
if ($sid && $sid != 2) {
Session::put('sid', $sid);
return Redirect::to('/students');
} elseif ($sid && $sid == 2) {
return Redirect::to('/students/login')->withErrors(array("msg" => "Password is invalid. Please Try again."));
} else {
return Redirect::to('/students/login')->withErrors(array("msg" => "Sorry!! Student of this email id does not exist."));
}
}
示例12: actionBatch
public function actionBatch()
{
if (isset($_POST['batch'])) {
$data = Students::model()->findAll('batch_id=:x', array(':x' => $_POST['batch']));
}
// echo CHtml::tag('option', array('value' => 0), CHtml::encode('Select'), true);
$data = CHtml::listData($data, 'id', 'phone1');
foreach ($data as $phoneno) {
if ($phoneno != "") {
echo $phoneno;
echo ",";
}
}
}
示例13: actionAddpoint
public function actionAddpoint($id)
{
$student = Students::model()->findByPk($id);
$bonus = new Points();
if (isset($_REQUEST['Points'])) {
$data = $_REQUEST['Points'];
$bonus->student = $data['student'];
$bonus->earned = $data['earned'];
$bonus->comment = $data['comment'];
$bonus->by = $data['by'];
if ($bonus->save()) {
Yii::app()->notify->add("Бонус добавлен");
} else {
Yii::app()->notify->addErrors($bonus->getErrors());
}
}
$this->render('addpoint', array('student' => $student, "point" => $bonus));
}
示例14: actionStudent
public function actionStudent()
{
if (isset($_POST['studentuser'])) {
$students = Students::model()->findAll(array('condition' => 'uid=:x and is_deleted=:y', 'params' => array(':x' => 0, ':y' => 0), 'limit' => '1000', 'order' => 'id ASC'));
if ($students != NULL) {
foreach ($students as $student) {
$user = new User();
$profile = new Profile();
if ($student->email != NULL) {
$user->username = substr(md5(uniqid(mt_rand(), true)), 0, 10);
$user->email = $student->email;
$user->activkey = UserModule::encrypting(microtime() . $student->first_name);
$password = substr(md5(uniqid(mt_rand(), true)), 0, 10);
$user->password = UserModule::encrypting($password);
$user->superuser = 0;
$user->status = 1;
if ($user->save()) {
//assign role
$authorizer = Yii::app()->getModule("rights")->getAuthorizer();
$authorizer->authManager->assign('student', $user->id);
//profile
$profile->firstname = $student->first_name;
$profile->lastname = $student->last_name;
$profile->user_id = $user->id;
$profile->save();
//saving user id to students table.
$student->saveAttributes(array('uid' => $user->id));
UserModule::sendMail($student->email, UserModule::t("You are registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please login to your account with your email id as username and password {password}", array('{password}' => $password)));
$flash = "User created successfully";
$type = 'success';
}
} else {
$flash = "No email id given";
$type = 'error';
}
}
}
Yii::app()->user->setFlash($type, $flash);
$this->redirect(array('/importcsv'));
} else {
$this->render('/default/student');
}
}
示例15: actionIndex
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function actionIndex()
{
$criteria = new CDbCriteria();
$criteria->condition = '';
$roles = Rights::getAssignedRoles(Yii::app()->user->id);
// check for single role
$user_roles = array();
foreach ($roles as $role) {
$user_roles[] = '"' . $role->name . '"';
}
$student = Students::model()->findByAttributes(array('uid' => Yii::app()->user->id));
$batch = Batches::model()->findByAttributes(array('id' => $student->batch_id));
$criteria->condition .= '`file`<>:null AND (`placeholder`=:null OR `placeholder` IN (' . implode(',', $user_roles) . ')) AND ((`course` IS NULL) OR (`course`=:course) OR (`course`=0)) AND ((`batch` IS NULL) OR (`batch`=:batch) OR (`batch`=0))';
$criteria->params = array(':null' => '', ':course' => $batch->course_id, ':batch' => $batch->id);
$criteria->order = '`created_at` DESC';
//print_r($criteria); exit;
$files = FileUploads::model()->findAll($criteria);
if (isset($_POST['Downfiles'])) {
$selected_files = $_POST['Downfiles'];
$slfiles = array();
foreach ($selected_files as $s_file) {
$model = FileUploads::model()->findByPk($s_file);
if ($model != NULL) {
$slfiles[] = 'uploads/shared/' . $model->id . '/' . $model->file;
}
}
$zip = Yii::app()->zip;
$fName = $this->generateRandomString(rand(10, 20)) . '.zip';
$zipFile = 'compressed/' . $fName;
if ($zip->makeZip($slfiles, $zipFile)) {
$fcon = file_get_contents($zipFile);
header('Content-type:text/plain');
header('Content-disposition:attachment; filename=' . $fName);
header('Pragma:no-cache');
echo $fcon;
unlink($zipFile);
} else {
Yii::app()->user->setFlash('success', 'Can\'t download');
}
}
$this->render('/fileUploads/index', array('files' => $files));
}