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 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 getSkillByCompanyID($CompanyID) { $db = PR_Database::getInstance(); $select = $db->select(); $select->from(array('o' => 'opportunity'), array('title')); $select->join(array('Opp_sk' => 'opportunity_skill'), 'Opp_sk.OpportunityID = o.OpportunityID', array('SkillID')); $select->where("o.CompanyID = '" . $CompanyID . "' "); $records = PR_Database::fetchAll($select); if (empty($records) && count($records) == 0) { return array(); } else { return $records; } }
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 getjobfunctionsid($JobFunctionID) { $db = PR_Database::getInstance(); $select = $db->select(); $select->from(array('jb' => 'jobfunction'), array('*')); $select->where("JobFunctionID = '{$JobFunctionID}'"); $records = PR_Database::fetchAll($select); if (!empty($records)) { return $records[0]; } else { return null; } }