/** * @param array $params * * @return array */ public function getMembers($params) { $search = ''; $table = 'users u'; if (!empty($params['sel_groups'])) { $table = 'citizen_groups cg, users u'; $search = " WHERE cg.citizen_id = u.id AND cg.group_id = {$params['sel_groups']} "; } return $this->connection->query('SELECT u.id, u.avatar, u.identity, u.gender, u.email, u.language, u.country, u.region, u.last_connected_at, u.created_at ' . "FROM {$table} {$search} ORDER BY u.identity ASC")->fetchAll(\PDO::FETCH_ASSOC); }
/** * {@inheritdoc} */ public function log($type, $message) { $this->connection->prepareStatement('INSERT INTO logs(type, message, created_at) VALUES(:type, :message, :created_at)', ['type' => $type, 'message' => $message, 'created_at' => (new \DateTime())->format('c')]); }
/** * @param int $motionId * @param int $memberId * @return int */ protected function hasAlreadyVoted($motionId, $memberId) { return $this->connection->query("SELECT COUNT(*) AS count FROM motions_votes_jetons WHERE Motion_id = {$motionId} AND Citizen_id = {$memberId}")->fetch(\PDO::FETCH_ASSOC)['count']; }
/** * @throws \PDOException */ public function throwPdoException() { throw new \PDOException("[{$this->connection->errorCode()}] {$this->connection->errorInfo()[2]}"); }