예제 #1
0
 /**
  * @param string $username
  * @param string $password
  * @return bool
  */
 public function tryLogin($username, $password)
 {
     $query = 'SELECT * FROM user WHERE username="******" AND password="******" LIMIT 1;';
     $this->db->setQuery($query);
     $this->db->query();
     return $this->db->loadObject();
 }
예제 #2
0
 /**
  * @param $username
  * @return bool
  */
 public function checkUsernameUniqueness($username)
 {
     $query = 'SELECT * FROM user WHERE username="******" LIMIT 1;';
     $this->db->setQuery($query);
     $this->db->query();
     if (!$this->db->loadObject()) {
         return true;
     } else {
         return false;
     }
 }
예제 #3
0
 /**
  * @param string $apikey
  * @return integer|null
  */
 public function getUserIdForApikey($apikey)
 {
     $this->db->setQuery('SELECT id FROM user WHERE apikey="' . $this->sanitize($apikey) . '" LIMIT 1;');
     $this->db->query();
     if (!empty($this->db->loadObject())) {
         return $this->db->loadObject()->id;
     } else {
         return null;
     }
 }
예제 #4
0
 /**
  * @param string $tableName
  * @param integer $recordId
  *
  * @return bool
  */
 public function delete($tableName, $recordId)
 {
     $this->db->setQuery('DELETE FROM ' . $tableName . ' WHERE id=' . $this->sanitize($recordId) . ';');
     $this->db->query();
     // If the query was successful, return true
     if ($this->db->getSqlstate() === '00000') {
         return true;
     } else {
         return false;
     }
 }