public function getRoles($id) { if (!$this->db->tableExists($this->table)) { return array(); } $query = "SELECT role FROM :::table WHERE id=:id ORDER BY role"; $bindings = array(':::table' => $this->table, ':id' => $id); $res = $this->db->fetch($query, $bindings); foreach ($res as $key => $row) { $res[$key] = $res[$key]['role']; } return $res; }
private function getEntireSize() { if ($this->db->tableExists($this->tableName)) { $query = 'SELECT count(id) AS numberOfEntries FROM :::table'; $bindings = array(':::table' => $this->tableName); $res = $this->db->fetch($query, $bindings); return (int) $res[0]['numberOfEntries']; } return 0; }
public function size() { $tableName = $this->table; if ($this->db->tableExists($tableName)) { $query = "SELECT count(idx) as numberOfEntries FROM :::table"; $res = $this->db->fetch($query, array(':::table' => $tableName)); return (int) $res[0]['numberOfEntries']; } return 0; }
/** * Fetches a user by a unique property (ID, e-mail address, username). * * @param string $property the name of the property * @param mixed $value the value * @return User null user object or <code>null</code> */ private function fetchByProperty($property, $value) { if (!$this->db->tableExists($this->table)) { return null; } $query = "SELECT * FROM :::table WHERE ::field=:value"; $bindings = array(':::table' => $this->table, '::field' => $property, ':value' => $value); $result = $this->db->fetch($query, $bindings); if (count($result) !== 1) { return null; } $user = new User($result[0]['id']); $user->setUsername($result[0]['username']); $user->setFullName($result[0]['fullName']); $user->setEmail($result[0]['email']); $user->setBirthdate($result[0]['birthdate']); $user->setGender($result[0]['gender']); $user->setTimezoneOffset($result[0]['timezoneOffset']); $user->setLocale($result[0]['locale']); $user->setLastLogin($result[0]['lastLogin']); $user->setSecret($result[0]['secret']); return $user; }