コード例 #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 null|integer $id
  * @return bool|null|\stdClass|\stdClass[]
  */
 public function get($tableName, $id = null)
 {
     if ($id === null) {
         $this->db->setQuery('SELECT * FROM ' . $tableName . ';');
         $this->db->query();
         if ($this->db->getSqlstate() === '00000') {
             return $this->db->loadObjectList();
         } else {
             return false;
         }
     } else {
         $this->db->setQuery('SELECT * FROM ' . $tableName . ' WHERE id = ' . $this->sanitize($id) . ';');
         $this->db->query();
         if ($this->db->getSqlstate() === '00000') {
             return $this->db->loadObject();
         } else {
             return false;
         }
     }
 }