private function initializeFlux() { $sql = "SELECT * FROM FLUX_ASSOC, FLUX WHERE ID = IDFLUX AND IDCATE = " . $this->id; $stmt = $this->pdo->query($sql); while ($result = $stmt->fetch()) { $newFlux = new FluxUser($result['IDFLUX'], $result['URL'], $result['NAME'], $result['ISFAVORITE']); $newFlux->initializeArticles(); array_push($this->flux, $newFlux); } }
public function addRSSFeedCategoryUser($nameFluxAdd, $nameCategorieToAdd, $urlFluxAdd) { $sql = "SELECT ID FROM CATEGORIE WHERE IDUSER = ? AND NAME = ?"; $this->pdo->prepare($sql); $this->pdo->execute(array($_SESSION['ID'], $nameCategorieToAdd)); $resultCate = $this->pdo->fetch(\PDO::FETCH_NUM); $idCate = $resultCate[0]; $sql = "SELECT COUNT(*) FROM FLUX WHERE URL = ?"; $this->pdo->prepare($sql); $this->pdo->execute(array($urlFluxAdd)); $resultVerif = $this->pdo->fetch(\PDO::FETCH_NUM); if ($resultVerif[0] == 0) { $sql = "INSERT INTO FLUX(URL) VALUES(?)"; $this->pdo->prepare($sql); $this->pdo->execute(array($urlFluxAdd)); $idFlux = $this->pdo->lastInsertId(); $sql = "INSERT INTO FLUX_ASSOC(IDCATE,IDFLUX,NAME,ISFAVORITE) VALUES(?,?,?,?)"; $this->pdo->prepare($sql); $this->pdo->execute(array($idCate, $idFlux, $nameFluxAdd, 0)); $flux = new FluxUser($idFlux, $urlFluxAdd, $nameFluxAdd, 0); $flux->refresh(); } else { $sql = "SELECT ID FROM FLUX WHERE URL = ?"; $this->pdo->prepare($sql); $this->pdo->execute(array($urlFluxAdd)); $resultFlux = $this->pdo->fetch(\PDO::FETCH_NUM); $idFlux = $resultFlux[0]; $sql = "INSERT INTO FLUX_ASSOC(IDCATE,IDFLUX,NAME,ISFAVORITE) VALUES(?,?,?,?)"; $this->pdo->prepare($sql); $this->pdo->execute(array($idCate, $idFlux, $nameFluxAdd, 0)); } }