/** * @param DBRecord $group * @throws \InvalidArgumentException * @return PDOStatement */ protected function prepareUpdateStatement(DBRecord $group) { if (!$group instanceof Group) { throw new InvalidArgumentException("Argument must be instance of " . __NAMESPACE__ . " class!"); } $conn = $this->getConnection(); $stmt = $conn->prepare('UPDATE ' . DBConfig::table(DBConfig::GROUPS) . ' SET name=:n, description=:d WHERE id=:id;'); $stmt->bindValue(':id', $group->getId(), PDO::PARAM_INT); $stmt->bindValue(':n', $group->getName(), PDO::PARAM_STR); $stmt->bindValue(':d', $group->getDescription(), PDO::PARAM_STR); return $stmt; }
/** * @param DBRecord $record * @throws InvalidArgumentException * @return PDOStatement */ protected function prepareUpdateStatement(DBRecord $record) { if (!$record instanceof Role) { throw new InvalidArgumentException("Object must be instance of Role class!"); } $conn = $this->getConnection(); $stmt = $conn->prepare('UPDATE ' . DBConfig::table(DBConfig::USERS) . ' SET login=:login, email=:email, activated=:status, firstname=:fn, surname=:sn WHERE id_u=:id;'); $stmt->bindValue(':id', $record->getId(), PDO::PARAM_INT); $stmt->bindValue(':login', $record->getLogin(), PDO::PARAM_STR); $stmt->bindValue(':email', $record->getEmail(), PDO::PARAM_STR); $stmt->bindValue(':status', $record->getStatus(), PDO::PARAM_INT); $stmt->bindValue(':fn', $record->getFirstname(), PDO::PARAM_STR); $stmt->bindValue(':sn', $record->getSurname(), PDO::PARAM_STR); return $stmt; }