public function geAllUser() { $db = PR_Database::getInstance(); $select = $db->select(); $select->from(array('u' => 'user'), array('*')); $records = PR_Database::fetchAll($select); return $records; }
public static function getConfigVal($cfgkey) { $db = PR_Database::getInstance(); $select = $db->select(); $select->from(PR_Database::TABLE_config); $select->where("cfgkey = ?", $cfgkey); $records = PR_Database::fetchAll($select); if (!empty($records)) { return $records[0]['cfgval']; } else { return ''; } }
public function getById($id) { $db = PR_Database::getInstance(); $select = $db->select(); $select->from("sections"); $select->where("section_id= '{$id}'"); $records = PR_Database::fetchAll($select); if (empty($records)) { return NULL; } else { return $records[0]; } }
public function checkUser($emailaddress) { $db = PR_Database::getInstance(); $select = $db->select(); $select->from('user'); $select->where("emailaddress = '{$emailaddress}'"); $records = PR_Database::fetchAll($select); if (!empty($records)) { return $records[0]; } else { return array("Error" => "This email is not found."); } }
public function GetSectionNum($sectionId) { $db = PR_Database::getInstance(); $select = $db->select(); $select->from(array('s' => 'sections'), array('s.students_num')); $select->where("section_id = '{$sectionId}'"); $records = PR_Database::fetchAll($select); if (!empty($records)) { return $records[0]['students_num']; } else { return 0; } }
public function getInfo() { $errors = PR_Api_Error::getInstance(); $db = PR_Database::getInstance(); $select = $db->select(); $select->from($this->_name, array('*')); $select->where($this->_pk . " = ?", $this->{$this->_pk}); //print_r($select->__toString()); $records = PR_Database::fetchAll($select); if (!empty($records) && count($records) > 0) { return $records[0]; } else { $errors->addError(3, 'Can not get object'); return null; } }
public function registerClient($data) { if (empty($data) || !is_array($data)) { return NULL; } $db = PR_Database::getInstance(); $ClientID = false; $mapping = array("firstname" => "firstname", "lastname" => "lastname", "emailaddress" => "emailaddress", "usertype" => "usertype", "password" => "password", "HeardFrom" => "HeardFrom", "loginname" => "loginname"); foreach ($data as $id => $value) { if (!array_key_exists($id, $mapping) || empty($value)) { continue; } $data[$mapping[$id]] = $value; } $primaryEmail = $data["emailaddress"]; $loginname = $data["loginname"]; // { $maxIdSql = "SELECT MAX(UserID) AS UserID FROM user"; $result = $db->fetchAll($maxIdSql); $User_ID = $result[0]['UserID'] + 1; $select = $db->select()->from(PR_Database::TABLE_USER, array('emailaddress')); $select->where("emailaddress = '{$primaryEmail}'"); $res = $db->fetchAll($select); $select1 = $db->select()->from(PR_Database::TABLE_USER, array('loginname')); $select1->where("loginname = '{$loginname}'"); $res1 = $db->fetchAll($select1); if (!empty($res) && count($res) > 0) { return array("error" => "email exists"); // echo("email exists"); } else { if (!empty($res1) && count($res1) > 0) { return array("error" => "User exists"); } else { if ($data['usertype'] == 1) { $db->insert(PR_Database::TABLE_USER, array("UserID" => $User_ID, "firstname" => $data['firstname'], "lastname" => $data['lastname'], "usertype" => $data['usertype'], "emailaddress" => $data['emailaddress'], "password" => $data['password'], "HeardFrom" => $data['HeardFrom'], "loginname" => $data['loginname'], "CompanyID" => "1")); } if ($data['usertype'] == 2) { $db->insert(PR_Database::TABLE_USER, array("UserID" => $User_ID, "firstname" => $data['firstname'], "lastname" => $data['lastname'], "usertype" => $data['usertype'], "emailaddress" => $data['emailaddress'], "password" => $data['password'], "HeardFrom" => $data['HeardFrom'], "loginname" => $data['loginname'])); } } } $db->commit(); }
public function add($userID, $institutionName) { if (empty($institutionName)) { return 0; } //--- get institution_id by $institutionName $db = PR_Database::getInstance(); $select = $db->select(); $select->from('institution', array('institution_id', 'institution_name')); $select->where("institution_name = '{$institutionName}'"); $records = PR_Database::fetchAll($select); $institution_id = 0; if (count($records) > 0) { $institution_id = $records[0]['institution_name']; } if ($institution_id > 0) { return $institution_id; } //--- $updateFields = array('institution_name' => $name, 'created_by_userid' => $userID, 'created_datetime' => date('Y-m-d H:i:s'), 'last_updated_by_userid' => $userID, 'last_updated_datetime' => date('Y-m-d H:i:s')); $id = PR_Database::insert("institution", $updateFields, true); return $id; }
public function publibOpportunityByOpportunityID($opportunityID, $status) { $db = PR_Database::getInstance(); $updateFields = array('status' => $status); $criteria = "OpportunityID = '{$opportunityID}'"; $result = PR_Database::update('opportunity', $updateFields, $criteria); return $result; }
public function registerClient($data) { if (empty($data) || !is_array($data)) { return NULL; } $db = PR_Database::getInstance(); $ClientID = false; $mapping = array("firstname" => "firstname", "lastname" => "lastname", "emailaddress" => "emailaddress", "usertype" => "usertype", "password" => "password", "HeardFrom" => "HeardFrom", "CompanyID" => "CompanyID"); foreach ($data as $id => $value) { if (!array_key_exists($id, $mapping) || empty($value)) { continue; } $data[$mapping[$id]] = $value; } $api = new PR_Api_Core_ClientClass(); $defaultCompany = $api->getDefaultCompany(); $defaultCompanyID = $defaultCompany['CompanyID']; // echo ("defaultCompanyID:".$defaultCompanyID); $primaryEmail = $data["emailaddress"]; $maxIdSql = "SELECT MAX(UserID) AS UserID FROM user"; $result = $db->fetchAll($maxIdSql); $User_ID = $result[0]['UserID'] + 1; $select = $db->select()->from(PR_Database::TABLE_USER, array('emailaddress')); $select->where("emailaddress = '{$primaryEmail}'"); $res = $db->fetchAll($select); if (!empty($res) && count($res) > 0) { return array("error" => "email exists"); echo "email exists"; } else { if ($data['usertype'] == 1) { // echo ("tetstt:<pre>");print_r($data);echo("</pre>");die(); $maxIdSql = "SELECT MAX(CompanyID) AS CompanyID FROM company"; $result = $db->fetchAll($maxIdSql); $CompanyID = $result[0]['CompanyID']; /* $Companyname=$data['Companyname']; $select1 = $db->select()->from(PR_Database::TABLE_COMPANY, array('Companyname')); $select1->where("Companyname = '$Companyname'"); $res1 = $db->fetchAll($select1); if(!empty($res1) && count($res1) > 0 ) { return array("error" => "Company name exists","CompanyID"=>""); echo("Companyname exists"); }else{ $updateFields=array( 'CompanyID'=>$CompanyID, 'Companyname'=>$data['Companyname'] ); $result = PR_Database::insert("company", $updateFields); // return $CompanyID; return array("error"=>"","CompanyID" => "$CompanyID"); } */ // $db->insert(PR_Database::TABLE_USER, array("UserID" => $User_ID, "firstname" => $data['firstname'], "lastname" => $data['lastname'], "usertype" => $data['usertype'], "emailaddress" => $data['emailaddress'], "password" => $data['password'], "HeardFrom" => $data['HeardFrom'], "CompanyID" => $CompanyID)); } if ($data['usertype'] == 2) { $db->insert(PR_Database::TABLE_USER, array("UserID" => $User_ID, "firstname" => $data['firstname'], "lastname" => $data['lastname'], "usertype" => $data['usertype'], "emailaddress" => $data['emailaddress'], "password" => $data['password'], "HeardFrom" => $data['HeardFrom'])); } } $db->commit(); }
public function getStateByStateCode($stateCode) { $db = PR_Database::getInstance(); $select = $db->select(); $select->from(array('s' => 'state'), array('*')); $select->where("s.state_code ='" . $stateCode . "'"); //print_r($select->__toString());die(); $result = PR_Database::fetchAll($select); return $result; }
public function updateCandidateAttribute($CandidateProfileID, $attrs) { $db = PR_Database::getInstance(); $select = $db->select(); $select->from(array('cav' => 'candidate_attribute_value'), array('*')); $select->where("cav.Candidate_ProfileID = '{$CandidateProfileID}'"); $records = PR_Database::fetchAll($select); if (count($records) > 0) { if (empty($attrs) || count($attrs) == 0) { $criteria = "Candidate_ProfileID = '{$CandidateProfileID}'"; $result = $db->delete('candidate_attribute_value', $criteria); } else { /*echo "<pre>"; echo "test1 = "; print_r($attributeIDs); echo "</pre>"; die();*/ //if database not exist $attrs then delete foreach ($records as $rec) { $database_Exist = $rec['AttributeID']; $flag_exsist = false; foreach ($attrs as $attrInfo) { if ($database_Exist == $attrInfo['attr_id']) { $flag_exsist = true; break; } } if (!$flag_exsist) { $criteria = "Candidate_ProfileID = '{$CandidateProfileID}' AND AttributeID = '{$database_Exist}'"; $result = $db->delete('candidate_attribute_value', $criteria); } } // if $attr not exist in database then insert, else update foreach ($attrs as $attributeInfo) { $attr_Exist = $attributeInfo['attr_id']; $flag_exsist = false; foreach ($records as $recordsInfo) { if ($attr_Exist == $recordsInfo['AttributeID']) { $updateFields = array('Candidate_ProfileID' => $CandidateProfileID, 'AttributeID' => $attributeInfo['attr_id'], 'Value' => $attributeInfo['attr_value'], 'YearsofExperience' => $attributeInfo['attr_YoE'], 'LevelofInterest' => $attributeInfo['attr_LevelofInterest']); $criteria = "Candidate_ProfileID = '{$CandidateProfileID}' AND AttributeID = '{$attr_Exist}'"; $result = PR_Database::update("candidate_attribute_value", $updateFields, $criteria); $flag_exsist = true; break; } } if (!$flag_exsist) { $updateFields = array('Candidate_ProfileID' => $CandidateProfileID, 'AttributeID' => $attributeInfo['attr_id'], 'Value' => $attributeInfo['attr_value'], 'YearsofExperience' => $attributeInfo['attr_YoE'], 'LevelofInterest' => $attributeInfo['attr_LevelofInterest']); $result = PR_Database::insert("candidate_attribute_value", $updateFields); } } } } else { if (!empty($attrs) && count($attrs) > 0) { foreach ($attrs as $id) { $updateFields = array('Candidate_ProfileID' => $CandidateProfileID, 'AttributeID' => $id['attr_id'], 'Value' => $id['attr_value'], 'YearsofExperience' => $id['attr_YoE'], 'LevelofInterest' => $id['attr_LevelofInterest']); $result = PR_Database::insert("candidate_attribute_value", $updateFields); } } } return true; }
public function getUserById($id) { $db = PR_Database::getInstance(); $select = $db->select(); $select->from(PR_Database::TABLE_users); $select->where("user_id = '{$id}'"); $users = PR_Database::fetchAll($select); if (empty($users)) { return NULL; } else { return $users[0]; } }
public function delete($testIDArray) { if (!is_array($testIDArray) || count($testIDArray) == 0) { return; } $criteria = "TestID IN (" . implode(",", $testIDArray) . ")"; $db = PR_Database::getInstance(); $select = $db->select(); $select->from('opportunity_test', array('TestID')); $select->where("TestID IN (" . implode(",", $testIDArray) . ")"); $records = PR_Database::fetchAll($select); $result = 0; if (!empty($records) && count($records) > 0) { $result = 0; } else { $result = $db->delete('test', $criteria); } return $result; }
/** * Load PR_Api_User By Username * @param string $username * @return boolean */ public function lookupUsername($username) { if (empty($username)) { return false; } $fieldList = array("user_id", "username", "name", "fname", "mname", "lname"); $fieldList = array_combine($fieldList, $fieldList); $db = PR_Database::getInstance(); $select = $db->select(); $select->from(PR_Database::TABLE_users, $fieldList)->where("username = ?", $username); $users = PR_Database::fetchAll($select); if (!empty($user)) { $this->authenticate = false; $this->user_id = $user[0]['user_id']; $this->username = $user[0]['username']; $this->name = $user[0]['name']; $this->fname = $user[0]['fname']; $this->mname = $user[0]['mname']; $this->lname = $user[0]['lname']; return true; } else { if (!$errors->hasErrors()) { $errors->addError(3, 'Cannot find user'); } $this->authenticate = false; $this->user_id = NULL; $this->username = NULL; $this->name = NULL; return false; } }
public function addCandidateEmploymentJob($userID, $companyName, $position, $startDate, $endDate, $description, $Text) { // echo "testt:<pre>";print_r(count($Text["JobFucntion1"]));echo("</pre>");die(); //candidate_employments:CandidateEmploymentID,CandidateProfileID, //CompanyName,PostionHeld,StartDate,EndDate,Description,LastUpdated,LastUpdatedByUserID $db = PR_Database::getInstance(); $maxIdSql = "SELECT MAX(CandidateEmploymentID) AS CandidateEmploymentID FROM candidate_employments"; $result = $db->fetchAll($maxIdSql); $CandidateEmploymentID = $result[0]["CandidateEmploymentID"] + 1; //echo "test";print_r($CandidateEmploymentID);die(); $candidateInfo = $this->getCandidateInfo($userID); if (count($candidateInfo) == 0) { return 0; } $candidateProfileID = $candidateInfo['CandidateProfileID']; if (empty($candidateProfileID)) { $candidateProfileID = $this->createCandidateProfileID($userID); } $updateFields = array('CandidateProfileID' => $candidateProfileID, 'CompanyName' => $companyName, 'PostionHeld' => $position, 'Description' => $description, 'LastUpdated' => date("Y-m-d H:i:s"), 'LastUpdatedByUserID' => $userID); if (!empty($startDate)) { $updateFields['StartDate'] = date("Y-m-d", strtotime($startDate)); } if (!empty($endDate)) { $updateFields['EndDate'] = date("Y-m-d", strtotime($endDate)); } $CandidateEmploymentID = PR_Database::insert('candidate_employments', $updateFields, true); /*if(!empty($JobFunctionID) && !empty($Percentage)) { PR_Database::insert('credentialexperiencejobfunction',array("JobFunctionID"=>$JobFunctionID,"CandidateEmploymentID"=>$CandidateEmploymentID,"Percentage"=>$Percentage)); }*/ if (!empty($Text)) { for ($i = 0; $i < count($Text["JobFucntion1"]); $i++) { // echo "JobFucntion:".$Text["JobFucntion1"][$i]." "."Percentage:".$Text["Percentage1"][$i]."<br>"; PR_Database::insert('credentialexperiencejobfunction', array("JobFunctionID" => $Text["JobFucntion1"][$i], "CandidateEmploymentID" => $CandidateEmploymentID, "Percentage" => $Text["Percentage1"][$i])); } } return $CandidateEmploymentID; }