public function addUser($firstName, $lastName, $email, $password) { $apikey = SHA1($email . $password . RAND() . time()); $stmt = $this->pdo->prepare("INSERT INTO `users` (`firstName`, `lastName`, `email`,`password`, `apikey`) VALUES (?, ?, ?, SHA1(?), ?)"); if ($stmt->execute(array($firstName, $lastName, $email, $password, $apikey))) { return $this->pdo->lastInsertId(); } else { return 0; } }
public function insertReview($restaurant_id, $user_id, $review) { $sql = "INSERT INTO reviews (restaurant_id, user_id, review) VALUES (:rid, :uid, :review)"; $q = $this->pdo->prepare($sql); if ($q->execute(array(':rid' => $restaurant_id, ':uid' => $user_id, ':review' => $review))) { return $this->selectFromId($this->pdo->lastInsertId()); } else { return 0; } }