本文整理汇总了PHP中School::model方法的典型用法代码示例。如果您正苦于以下问题:PHP School::model方法的具体用法?PHP School::model怎么用?PHP School::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类School
的用法示例。
在下文中一共展示了School::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionEditmoreinfo
public function actionEditmoreinfo($user_id)
{
$user_more_info = UserInfoAR::model()->findByPk($user_id);
$this->assign('user_more', $user_more_info);
$maritalStatus = MaritalStatus::model()->findAll();
// 'MaritalStatus', 'marital_status_id'),
$hometown = Hometown::model()->findAll();
// 'Province', 'hometown_id'),
$nation = Nation::model()->findAll();
// 'Nation', 'nation_id'),
$bodyType = BodyType::model()->findAll();
// 'BodyType', 'body_type_id'),
$education = Education::model()->findAll();
// 'Education', 'education_id'),
$school = School::model()->findAll();
// 'School', 'school_id'),
$province = Province::model()->findAll();
// 'Province', 'province_id'),
$job = Job::model()->findAll();
// '$maritalSta,
$this->assign('maritalStatus', $maritalStatus);
$this->assign('hometown', $hometown);
$this->assign('nation', $nation);
$this->assign('bodyType', $bodyType);
$this->assign('education', $education);
$this->assign('school', $school);
$this->assign('province', $province);
$this->assign('job', $job);
}
示例2: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return School the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = School::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例3: getAllSchools
/**
* Returns array of all schools
*/
public static function getAllSchools()
{
$schools = School::model()->findAll();
$schoolNames = array();
foreach ($schools as $school) {
$schoolNames[] = $school->name;
}
return $schoolNames;
}
示例4: actionGetSchoolList
public function actionGetSchoolList()
{
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
$maxmarkers = 5000;
$result = array();
$result['SchoolList'] = array();
if (empty($_POST)) {
$result['IsError'] = true;
$result['Message'] = '数据接收失败';
} else {
$result['IsError'] = false;
//type
$criteria = new CDbCriteria();
if ($_POST['type'] == 's') {
$criteria->addCondition('type =1');
}
if ($_POST['type'] == 'e') {
$criteria->addCondition('type =0');
}
if (!empty($_POST['province'])) {
$criteria->addCondition('province="' . $_POST['province'] . '"');
}
$chinese = preg_match("/\\p{Han}+/u", $_POST['xingzhi']);
//XingZhi
if (!empty($_POST['xingzhi']) && !$chinese) {
$criteria->addCondition("xingzhi like '" . $_POST['xingzhi'] . "%'");
}
//Pingfen
if (!empty($_POST['pingfen']) && intval($_POST['pingfen']) > 0) {
$criteria->addCondition("pingfen >='" . $_POST['pingfen'] . "'");
}
//Rank
//$criteria->order = "paiming ASC";
$criteria->addCondition("paiming >=1");
//End of Condition
$count = School::model()->count($criteria);
//Display school list if maxmarker is less
$criteria->order = "paiming";
$school = School::model()->findAll($criteria);
foreach ($school as $val) {
$paiming = !empty($val->paiming) ? $val->paiming : '无';
$rating = !empty($val->pingfen) ? $val->pingfen : '无';
$result["SchoolList"][] = array($paiming, $val->school, $val->grade, $val->address, $val->city, $val->tel, $val->id);
}
}
echo json_encode($result);
}
示例5: importCompetitiors
public function importCompetitiors($competition_id, $competition_category_id, $content)
{
$lines = explode("\n", $content);
$header = explode(';', $lines[0]);
$competition_questions = CompetitionQuestionCategory::model()->with('competitionQuestion')->with('competitionQuestion.question')->findAll('competition_category_id=:competition_category_id and competitionQuestion.competition_id=:competition_id', array(':competition_category_id' => $competition_category_id, ':competition_id' => $competition_id));
$questions_to_import = array();
foreach ($competition_questions as $cq) {
if ($cq == null) {
$cq = new CompetitionQuestionCategory();
}
$questions_to_import[trim($cq->competitionQuestion->question->title)] = $cq->competition_question_id;
}
echo 'Question to import:<br />';
pre_print($questions_to_import);
// map fields
$colQuestionMap = array();
$found_c = array();
for ($i = 0; $i < count($header); ++$i) {
$col = explode('(', $header[$i]);
$c = trim($col[0]);
if (isset($questions_to_import[$c])) {
$colQuestionMap[$i] = $questions_to_import[$c];
$found_c[] = $c;
}
}
if (count($colQuestionMap) != count($questions_to_import)) {
echo 'Question to import and question in CSV does not match!';
echo 'Question to import:<br />';
pre_print($questions_to_import);
echo 'Found questions: <br />';
pre_print($found_c);
echo 'CSV header line cols: <br />';
pre_print($header);
echo 'Question column mapping found:<br />';
pre_print($colQuestionMap);
die;
} else {
echo 'Question column exist, we can start importing.<br />';
}
// check for required columns
$required_fields = array('Priimek' => -1, 'Ime' => -1, 'Mentor' => -1, 'Šola' => -1, 'Spol' => -1, 'Razred' => -1);
$required_keys = array_keys($required_fields);
// not required fields
$required_fields['ID1'] = -1;
$required_fields['ID2'] = -1;
$required_keys2 = array_keys($required_fields);
for ($i = 0; $i < count($header); ++$i) {
if (in_array(trim($header[$i]), $required_keys2)) {
$required_fields[trim($header[$i])] = $i;
}
}
$missing_fields = array();
for ($i = 0; $i < count($required_keys); ++$i) {
if ($required_fields[$required_keys[$i]] == -1) {
$missing_fields[] = $required_keys[$i];
}
}
if (count($missing_fields) > 0) {
echo 'Some required fields are missing:<br />';
pre_print($missing_fields);
die;
}
$competition = Competition::model()->findByPk($competition_id);
if ($competition == null) {
echo 'Provided Competition does not exist!';
die;
}
$competitionCategory = CompetitionCategory::model()->findByPk($competition_category_id);
if ($competitionCategory == null) {
echo 'Provided Competition Category does not exist!';
die;
}
for ($i = 1; $i < count($lines); ++$i) {
if (trim($lines[$i]) == '') {
continue;
}
$cols = explode(';', $lines[$i]);
$cu = new CompetitionUser();
$cu->competition_category_id = $competition_category_id;
$cu->competition_id = $competition_id;
$cu->first_name = $cols[$required_fields['Ime']];
$cu->last_name = $cols[$required_fields['Priimek']];
$cu->gender = $cols[$required_fields['Spol']] == 'M' ? 0 : 1;
$cu->class = $cols[$required_fields['Razred']];
$sc = School::model()->find('name=:name', array(':name' => trim($cols[$required_fields['Šola']])));
if ($sc == null) {
echo 'Provided school not found in database! School name: ', $cols[$required_fields['Šola']], '<br />';
die;
}
$cu->school_id = $sc->id;
$scm = SchoolMentor::model()->with('user.profile')->find('school_id=:school_id and CONCAT_WS(\' \', `profile`.`last_name`, `profile`.`first_name`) LIKE :mentor', array(':school_id' => $sc->id, ':mentor' => trim($cols[$required_fields['Mentor']])));
if ($scm == null) {
echo 'Provided school mentor not found in database! School name: ', $cols[$required_fields['Šola']], ', School mentor: ', $cols[$required_fields['Mentor']], '<br />';
die;
}
// ali je šola prijavljena na tekmovanje za to kategorijo
$ccs = CompetitionCategorySchool::model()->find('competition_id=:competition_id and competition_category_id=:competition_category_id and school_id=:school_id', array(':competition_id' => $competition_id, ':competition_category_id' => $competition_category_id, ':school_id' => $sc->id));
if ($ccs == null) {
echo 'Provided school is not competing in this category! School name: ', $cols[$required_fields['Šola']], ', Competition: ', $competition->name, ', Competition category: ', $competitionCategory->name, '<br />';
die;
//.........这里部分代码省略.........
示例6: foreach
?>
"><?php
echo $js->username;
?>
</a></td>
<td><?php
echo $js->first_name . " " . $js->last_name;
?>
</td>
<td><?php
$educ = Education::model()->findByAttributes(array('FK_user_id' => $js->id));
$school = "";
if ($educ) {
$school = School::model()->findByAttributes(array('id' => $educ->FK_school_id))->name;
}
echo $school;
?>
</td>
<td class="info1">
<?php
$temp = StudentSkillMap::model()->findAllByAttributes(array('userid' => $js->id));
foreach ($temp as $one) {
echo Skillset::model()->findByAttributes(array('id' => $one->skillid))->name . " - ";
}
?>
</td>
</tr>
<?php
示例7: import
public function import($content)
{
$header_cols = array('name' => 0, 'school_category_id' => 1, 'level_of_education' => 2, 'post' => 3, 'postal_code' => 4, 'municipality_id' => 5, 'region_id' => 6, 'country_id' => 7);
header('Content-Type: text/html; charset=utf-8');
$lines = explode("\n", $content);
for ($i = 1; $i < count($lines); ++$i) {
if (trim($lines[$i]) == '') {
continue;
}
$cols = explode(";", $lines[$i]);
// država
$country_id = 0;
$country = Country::model()->find('country=:country', array(':country' => trim($cols[$header_cols['country_id']])));
if ($country == null) {
echo Yii::t('app', 'Country does not exist! Country: ') . trim($cols[$header_cols['country_id']]);
die;
}
$country_id = $country->id;
// regija
$region = Region::model()->find('name=:name and country_id=:country_id', array(':name' => trim($cols[$header_cols['region_id']]), ':country_id' => $country_id));
if ($region == null) {
$region = new Region();
$region->country_id = $country_id;
$region->name = trim($cols[$header_cols['region_id']]);
$region->save();
}
$region_id = $region->id;
// občina
$municipality = Municipality::model()->find('name=:name and country_id=:country_id', array(':name' => trim($cols[$header_cols['municipality_id']]), ':country_id' => $country_id));
if ($municipality == null) {
$municipality = new Municipality();
$municipality->country_id = $country_id;
$municipality->name = trim($cols[$header_cols['municipality_id']]);
$municipality->save();
}
$municipality_id = $municipality->id;
$school_name = trim($cols[$header_cols['name']]);
if ($school_name[0] == '"') {
$school_name = mb_substr($school_name, 1, mb_strlen($school_name, 'UTF-8') - 2, 'UTF-8');
}
$school_name = str_replace('""', '"', $school_name);
$school = School::model()->find('name=:name and country_id=:country_id', array(':name' => $school_name, ':country_id' => $country_id));
if ($school == null) {
$school = new School();
$school->name = $school_name;
$school->country_id = $country_id;
$school->municipality_id = $municipality_id;
$school->region_id = $region_id;
$school->post = trim($cols[$header_cols['post']]);
$school->postal_code = trim($cols[$header_cols['postal_code']]);
$school->school_category_id = (int) trim($cols[$header_cols['school_category_id']]);
$school->level_of_education = (int) trim($cols[$header_cols['level_of_education']]);
$school->save();
echo 'Imported: ', $school_name, "<br />\n";
if (count($school->errors) > 0) {
print_r($school->errors);
die;
}
} else {
echo 'Already imported: ', $school_name, "<br />\n";
}
}
}
示例8: SyncZavodiWhereKategorijaActive
public static function SyncZavodiWhereKategorijaActive()
{
$schoolCategories = SchoolCategory::model()->findAll('active=:active', array(':active' => 1));
$kategorije = array();
$kategorija_map = array();
foreach ($schoolCategories as $schoolCategory) {
$kategorije[] = $schoolCategory->name;
$kategorija_map[$schoolCategory->name] = $schoolCategory->id;
}
echo "Current categories for sync:<br />";
pre_print($kategorije);
$list = self::GetRegZavod();
if (!isset($list['return'])) {
return array();
}
$list = $list['return'];
echo "Current schools to sync:<br />";
$country = Country::model()->find('country=:country', array(':country' => 'Slovenija'));
if ($country == null) {
echo "Add country Slovenija!<br />\n";
die;
}
$country_id = $country->id;
// cache all občine
$municipalities = Municipality::model()->findAll('country_id=:country_id', array(':country_id' => $country_id));
$municipality_map = array();
foreach ($municipalities as $municipality) {
$municipality_map[$municipality->name] = $municipality->id;
}
// cache all regije
$regions = Region::model()->findAll('country_id=:country_id', array(':country_id' => $country_id));
$region_map = array();
foreach ($regions as $region) {
$region_map[$region->name] = $region->id;
}
$counter = 0;
$updated = 0;
$inserted = 0;
for ($i = 0; $i < count($list); ++$i) {
if (in_array($list[$i]['KATEGORIJA'], $kategorije)) {
$counter++;
$el = $list[$i];
$school = School::model()->find('name=:name and country_id=:country_id', array(':name' => trim($el['ZAVOD_NAZIV']), ':country_id' => $country_id));
if ($school == null) {
$school = new School();
$school->name = trim($el['ZAVOD_NAZIV']);
$school->country_id = $country_id;
$inserted++;
}
$school->school_category_id = $kategorija_map[trim($el['KATEGORIJA'])];
// občina
if (!isset($municipality_map[trim($el['OBCINANAZIV'])])) {
$municipality = new Municipality();
$municipality->name = trim($el['OBCINANAZIV']);
$municipality->country_id = $country_id;
$municipality->save();
$municipality_map[trim($el['OBCINANAZIV'])] = $municipality->id;
}
$school->municipality_id = $municipality_map[trim($el['OBCINANAZIV'])];
// regija
if (!isset($region_map[trim($el['REGIJANAZIV'])])) {
$region = new Region();
$region->name = trim($el['REGIJANAZIV']);
$region->country_id = $country_id;
$region->save();
$region_map[trim($el['REGIJANAZIV'])] = $region->id;
}
$school->region_id = $region_map[trim($el['REGIJANAZIV'])];
$school->post = trim($el['POSTANAZIV']);
$school->postal_code = trim($el['POSTASIFRA']);
$school->identifier = trim($el['ZAVPRS']);
$school->headmaster = trim($el['ZAVRAVN']);
if (isset($el['ZAVDAVST'])) {
$school->tax_number = trim($el['ZAVDAVST']);
}
if ($school->save()) {
$updated++;
}
}
}
echo 'Found schools to sync: ', $counter, "<br />\n";
echo 'New schools imported: ', $inserted, "<br />\n";
echo 'Updated schools: ', $updated - $inserted, "<br />\n";
}
示例9: actionRestresetpassword
/**
* 重置某个园所有未激活用户的密码为手机后四位
* GET /school/{schoolId}/user/reset
*/
public function actionRestresetpassword()
{
// check school
if (isset($_GET['schoolId'])) {
$school = School::model()->findByPk($_GET['schoolId']);
if ($school == null || $school->archived == 0) {
return $this->sendResponse(404, 'school is not found');
}
}
$criteria = new CDbCriteria();
$criteria->compare('archived', 1);
$criteria->order = 'created_time desc';
if (isset($_GET['schoolId'])) {
$criteria->compare('school_id', $_GET['schoolId']);
}
$criteria->compare('open_id', null);
$users = User::model()->findAll($criteria);
$count = 0;
foreach ($users as $user) {
if ($user->open_id != null) {
continue;
}
$password = substr($user->mobile, -4);
if ($user->password != User::model()->encrypt($password)) {
$count++;
$user->username = trim($user->username);
$user->mobile = trim($user->mobile);
$user->password = $password;
if (!$user->save()) {
return $this->sendResponse(500, 'failed to reset password ' . $user->id);
} else {
/*
Notification::addNotification(
$user->id,
"您的优购优惠券管理后台激活密码已重置为您手机号码的后四位,请使用新密码激活您在优购优惠券管理后台的账号。如需帮助,请发邮件至support@yougouwx.com。对您造成的不便深表歉意。",
1
);*/
}
}
}
echo CJSON::encode($count);
}
示例10: GetSchoolName
public function GetSchoolName($id)
{
$school = School::model()->findByPk($id);
if ($school != null) {
return $school->name;
} else {
return '';
}
}
示例11: importMentorsWithCodes
public function importMentorsWithCodes($competition_id, $country_id, $csv)
{
$country = Country::model()->findByPk($country_id);
if ($country == null) {
echo 'Country does not exist!';
die;
}
header('Content-Type: text/html; charset=utf-8');
if ($country->country == 'Srbija') {
// popravek imen kategorij, ki se parsajo
$cols = array('E-poštni naslov' => 'email', 'Telefon' => 'phone', 'Ime' => 'name', 'Priimek' => 'surname', 'Država' => 'country', 'Ime škole' => 'school', 'Koordinator' => 'coordinator_on_school', 'Uporabniško ime' => 'username', 'Geslo' => 'password', 'Dabarčić' => 'category_name_Dabarčić', 'Mladi dabar' => 'category_name_Mladi dabar', 'Dabar' => 'category_name_Dabar', 'Stariji dabar' => 'category_name_Stariji dabar');
} else {
$cols = array('E-poštni naslov' => 'email', 'Telefonska številka' => 'phone', 'Ime' => 'name', 'Priimek' => 'surname', 'Država' => 'country', 'Šola' => 'school', 'Koordinator' => 'coordinator_on_school', 'Uporabniško ime' => 'username', 'Geslo' => 'password', 'Bobrček' => 'category_name_Bobrček', 'Mladi bober' => 'category_name_Mladi bober', 'Bober' => 'category_name_Bober', 'Stari bober' => 'category_name_Stari bober');
}
$lines = explode("\n", trim($csv));
$header_line = $lines[0];
$header_cols = explode(';', trim($header_line));
$keys = array_keys($cols);
$cols_matrix = array();
$index = 0;
foreach ($header_cols as $h_cols) {
$h_cols = trim($h_cols);
if (in_array($h_cols, $keys)) {
$cols_matrix[$index] = $cols[$h_cols];
echo "Found:", $h_cols, "<br />";
} else {
echo "Not found:", $h_cols, "<br />";
}
$index++;
}
if (count($cols_matrix) != count($cols)) {
echo 'One of required header columns is missing. Required columns: ', implode(', ', $keys), "<br />";
echo 'Got cols: ', implode(', ', $header_cols), "<br />";
echo 'Cols matrix: ', implode(', ', $cols_matrix), "<br />";
die;
}
// pre_print($cols_matrix);
$datas = array();
for ($i = 1; $i < count($lines); ++$i) {
$col = explode(';', trim($lines[$i]));
$data = array();
$index = 0;
foreach ($col as $c) {
$data[$cols_matrix[$index]] = trim($c);
if (count(explode('category_name_', $cols_matrix[$index])) > 1 && in_array($data[$cols_matrix[$index]], array('srednja šola', 'osnovna šola', 'srednja šola)', 'osnovna šola)', 'Samo za srednje', 'Samo za osnovne'))) {
$data[$cols_matrix[$index]] = '';
} else {
if ($cols_matrix[$index] == 'coordinator_on_school') {
if ($data[$cols_matrix[$index]] != '') {
$data['coordinator'] = true;
} else {
$data['coordinator'] = false;
}
} else {
if ($cols_matrix[$index] == 'school') {
$school_name = trim($data['school']);
if ($school_name[0] == '"') {
$school_name = mb_substr($school_name, 1, mb_strlen($school_name, 'UTF-8') - 2, 'UTF-8');
}
$school_name = str_replace('""', '"', $school_name);
$school_check = School::model()->find('name=:name', array(':name' => $school_name));
if ($school_check != null) {
$data['school_id'] = $school_check->id;
} else {
echo 'Šola ne obstaja! Šola: ', $data['school'], '<br />';
}
} else {
if ($cols_matrix[$index] == 'username') {
$data[$cols_matrix[$index]] = str_replace('.', '', $data[$cols_matrix[$index]]);
$data[$cols_matrix[$index]] = str_replace('á', 'a', $data[$cols_matrix[$index]]);
}
}
}
}
$index++;
}
if ($data['email'] == '' && $data['name'] == '') {
continue;
}
if (count($data) != count($keys) + 2) {
echo 'Record is invalid, it does not have all required fields. Skipping...<br />';
echo count($data), ' vs. ', count($keys) + 2, '...<br />';
pre_print($keys);
pre_print($data);
continue;
}
$datas[] = $data;
}
// pre_print($datas);
// category matching to ids in database
$category_matching = array();
foreach ($cols_matrix as $mc) {
$ex = explode('category_name_', $mc);
if (count($ex) > 1) {
$category_name = $ex[1];
$competitionCategory = CompetitionCategory::model()->find('name=:name', array(':name' => $category_name));
if ($competitionCategory == null) {
echo 'Competition category ', $category_name, ' not found in database!<br />';
die;
} else {
//.........这里部分代码省略.........
示例12: beforeDelete
protected function beforeDelete()
{
//ko co id teacher nhu o afterSave nen phai get lay
$getID= PostsComments::model()->findAll(
array("condition"=>"commentId=$this->id"));
$li = CHtml::listData($getID,'postId','commentId');
$key=key($li);
$model2 = School::model()->findAll(
array("condition"=>"id = $key",'select'=>'rate1,rate2,rate3,rate4,rate5,count',));
if ($model2<>NULL)
{
self::minusPointTeacher($model2,$key);
}
$models = Teacher::model()->findAll(
array("condition"=>"id = $key",'select'=>'rate1,rate2,rate3,rate4,rate5,count',));
if ($models<>NULL)
{
self::minusPointSchool($models,$key);
}
return parent::beforeDelete();
}
示例13: actionRegisterLinkedIn
public function actionRegisterLinkedIn()
{
// if user canceled, redirect to home page
if (isset($_GET['oauth_problem'])) {
$problem = $_GET['oauth_problem'];
if ($problem == 'user_refused') {
$this->redirect('/JobFair/index.php');
}
}
if (!isset($_SESSION)) {
session_start();
}
//edit by Manuel making the link dynamic, using Yii
$config['base_url'] = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/user/auth1.php';
$config['callback_url'] = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/user/RegisterLinkedIn';
$config['linkedin_access'] = '2rtmn93gu2m4';
$config['linkedin_secret'] = 'JV0fYG9ls3rclP8v';
include_once Yii::app()->basePath . "/views/user/linkedin.php";
# First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
$linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['callback_url']);
//$linkedin->debug = true;
if (isset($_REQUEST['oauth_verifier'])) {
$_SESSION['oauth_verifier'] = $_REQUEST['oauth_verifier'];
$linkedin->request_token = unserialize($_SESSION['requestToken']);
$linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
$linkedin->getAccessToken($_REQUEST['oauth_verifier']);
$_SESSION['oauth_access_token'] = serialize($linkedin->access_token);
header("Location: " . $config['callback_url']);
exit;
} else {
$linkedin->request_token = unserialize($_SESSION['requestToken']);
$linkedin->oauth_verifier = $_SESSION['oauth_verifier'];
$linkedin->access_token = unserialize($_SESSION['oauth_access_token']);
}
# You now have a $linkedin->access_token and can make calls on behalf of the current member
$xml_response = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url,industry,email-address,languages,phone-numbers,skills,educations,location:(name),positions,picture-urls::(original))");
$data = simplexml_load_string($xml_response);
// get user by linkedinid
$model = new User();
$user = User::model()->findByAttributes(array('linkedinid' => $data->id));
// check if user exits in database, if so login
if ($user != null) {
if ($user->disable != 1) {
$identity = new UserIdentity($user->username, '');
if ($identity->authenticateOutside()) {
Yii::app()->user->login($identity);
}
$this->redirect("/JobFair/index.php/home/studenthome");
return;
} else {
$this->redirect("/JobFair/index.php/site/page?view=disableUser");
return;
}
// register
} else {
// print "<pre>"; print_r('user is null');print "</pre>";
// check that there is no duplicate user if so link to that account
$duplicateUser = User::model()->findByAttributes(array('email' => $data->{'email-address'}));
if ($duplicateUser != null) {
// get username and link the accounts
$username = $duplicateUser->username;
$user = User::model()->find("username=:username", array(':username' => $username));
$user->linkedinid = $data->{'id'};
$user->save(false);
$user_id = $user->id;
// ------------------BASIC INFO---------------
$basic_info = null;
$basic_info = BasicInfo::model()->findByAttributes(array('userid' => $user_id));
if ($basic_info == null) {
$basic_info = new BasicInfo();
}
$basic_info->userid = $user_id;
$basic_info->save(false);
// ------------------BASIC INFO -----------------
// -----------------EDUCATION ----------------------
// get number of educations to add
$educ_count = $data->educations['total'];
// delete current educations
$delete_educs = Education::model()->findAllByAttributes(array('FK_user_id' => $user_id));
foreach ($delete_educs as $de) {
$de->delete();
}
// add educations
for ($i = 0; $i < $educ_count; $i++) {
// first check if current education is in school table. if not, add it
$current_school_name = $data->educations->education[$i]->{'school-name'};
$school_exists = School::model()->findByAttributes(array('name' => $current_school_name));
if ($school_exists == null) {
$new_school = new School();
$new_school->name = $current_school_name;
$new_school->save();
$school_id = School::model()->findByAttributes(array('name' => $current_school_name))->id;
} else {
$school_id = $school_exists->id;
}
// now ready to add new education
$new_educ = new Education();
$new_educ->degree = $data->educations->education[$i]->degree;
$new_educ->major = $data->educations->education[$i]->{'field-of-study'};
// $model->admission_date=date('Y-m-d',strtotime($model->admission_date));
//.........这里部分代码省略.........
示例14: actionEmployersearch
public function actionEmployersearch()
{
$srch_keyword = $_POST['skillkeyword'];
// Get skill keyword to search
$pieces = trim($srch_keyword);
$pieces = explode(" ", $pieces);
// split words to search
$count = sizeof($pieces);
// get number of word to search
$query = '';
for ($i = 0; $i < $count; $i++) {
if ($i == $count - 1) {
$query = $query . 'name like \'%' . $pieces[$i] . '%\'';
} else {
$query = $query . 'name like \'%' . $pieces[$i] . '%\' OR ';
}
}
$criteria = new CDbCriteria();
$criteria->condition = $query;
$results = array();
if ($srch_keyword != null) {
$skillsArray = Skillset::model()->findAll($criteria);
foreach ($skillsArray as $sk) {
$student_ids = StudentSkillMap::model()->findAllByAttributes(array('skillid' => $sk->id));
// search student skill map for students with that skill
foreach ($student_ids as $tmp) {
$duplicate = 0;
if (sizeof($results) > 0) {
foreach ($results as $t) {
if ($t->id == $tmp->userid) {
$duplicate = 1;
}
}
}
if ($duplicate == 0) {
$results[] = User::model()->findByAttributes(array('id' => $tmp->userid));
}
}
}
$school_id = School::model()->findAll($criteria);
// get school ID
foreach ($school_id as $si) {
$student_ids = Education::model()->findAllByAttributes(array('FK_school_id' => $si->id));
// search educations with school ID
foreach ($student_ids as $tmp) {
$duplicate = 0;
if (sizeof($results) > 0) {
foreach ($results as $t) {
if ($t->id == $tmp->FK_user_id) {
$duplicate = 1;
}
}
}
if ($duplicate == 0) {
$results[] = User::model()->findByAttributes(array('id' => $tmp->FK_user_id));
}
}
}
}
if (isset($_GET['user'])) {
$username = $_GET['user'];
} else {
$username = Yii::app()->user->name;
}
$user = User::model()->find("username=:username", array(':username' => $username));
// pass user
$skills = Skillset::getNames();
// pass skills
$universites = School::getAllSchools();
// pass companies
// foreach ($results as $tr){
// print "<pre>"; print_r($tr->attributes);print "</pre>";
// }
// return;
$this->render('employerSearchResults', array('results' => $results, 'skills' => $skills, 'universities' => $universites, 'user' => $user));
}
示例15: actionGetSchoolMap
public function actionGetSchoolMap()
{
$_POST = (array) json_decode(file_get_contents('php://input'), true);
$postParms = !empty($_POST['parms']) ? $_POST['parms'] : array();
$maxmarkers = 200;
$result = array();
$result['SchoolList'] = array();
if (empty($_POST)) {
$result['IsError'] = true;
$result['Message'] = '数据接收失败';
} else {
$result['IsError'] = false;
//type
$criteria = new CDbCriteria();
if ($postParms['type'] == TRUE) {
//secondary school
$criteria->addCondition('type =1');
}
/*
if($postParms['type'] == FALSE ) { //elementary school
$criteria->addCondition('type =0');
} */
$chinese = preg_match("/\\p{Han}+/u", $postParms['xingzhi']);
//XingZhi
if (!empty($postParms['xingzhi']) && !$chinese) {
$criteria->addCondition("xingzhi like '" . $postParms['xingzhi'] . "%'");
}
//Pingfen
if (!empty($postParms['pingfen']) && intval($postParms['pingfen']) > 0) {
$criteria->addCondition("pingfen >='" . $postParms['pingfen'] . "'");
}
//Rank
if (!empty($postParms['rank']) && intval($postParms['rank']) > 0) {
//$criteria->order = "paiming ASC";
$criteria->addCondition("paiming <='" . $postParms['rank'] . "'");
}
//lat and long selection
if (!empty($postParms['bounds'])) {
$latlon = explode(',', $postParms['bounds']);
$minLat = floatval($latlon[0]);
$maxLat = floatval($latlon[2]);
$minLon = floatval($latlon[1]);
$maxLon = floatval($latlon[3]);
$criteria->addCondition("lat <= :maxLat");
$criteria->params += array(':maxLat' => $maxLat);
$criteria->addCondition("lat >= :minLat");
$criteria->params += array(':minLat' => $minLat);
$criteria->addCondition("lng <= :maxLon");
$criteria->params += array(':maxLon' => $maxLon);
$criteria->addCondition("lng >= :minLon");
$criteria->params += array(':minLon' => $minLon);
}
//Filter Invalid Lat
$criteria->addCondition("lat > 20");
//End of Condition
$count = School::model()->count($criteria);
//Display grid list if # of maxmarker is large
if ($count >= $maxmarkers) {
$result['type'] = "grid";
$criteria->addCondition("pingfen >0");
error_log("Count:" . $count . "Grid Mode");
$criteria->limit = 2000;
$school = School::model()->findAll($criteria);
$result['Message'] = '成功';
$gridx = $postParms['gridx'] ? $postParms['gridx'] : 5;
$gridy = $postParms['gridy'] ? $postParms['gridy'] : 5;
$tiley = ($maxLat - $minLat) / $gridy;
$tilex = ($maxLon - $minLon) / $gridx;
//Generate grid center Lat/Lng
for ($x = 1; $x <= $gridx; $x++) {
for ($y = 1; $y <= $gridy; $y++) {
$gridCenterlat = $minLat + $tiley / 2 + ($y - 1) * $tiley;
$gridCenterlng = $minLon + $tilex / 2 + ($x - 1) * $tilex;
$result['gridList']["G" . $x . $y]['GeocodeLat'] = $gridCenterlat;
$result['gridList']["G" . $x . $y]['GeocodeLng'] = $gridCenterlng;
}
}
//Get count of school in each tile
foreach ($school as $val) {
$gridlat = ceil(($val->lat - $minLat) / $tiley);
$gridlng = ceil(($val->lng - $minLon) / $tilex);
$rating = $val->pingfen;
$result['gridList']["G" . $gridlng . $gridlat]['GridName'] = "G" . $gridlng . $gridlat;
$result['gridList']["G" . $gridlng . $gridlat]['SchoolCount']++;
$result['gridList']["G" . $gridlng . $gridlat]['TotalRating'] += $rating;
}
}
//Display school list if maxmarker is less
if ($count < $maxmarkers) {
$result['type'] = "school";
$criteria->order = "paiming";
$school = School::model()->findAll($criteria);
$result['Message'] = '成功';
foreach ($school as $val) {
$schoolList = array();
$schoolList['School'] = $val->school;
$schoolList['Paiming'] = !empty($val->paiming) ? $val->paiming : '无';
$schoolList['Pingfen'] = !empty($val->pingfen) ? $val->pingfen : '无';
$schoolList['Grade'] = $val->grade;
$schoolList['City'] = $val->city;
//.........这里部分代码省略.........