conn = $db; $this->score_path = $path; } // read score list public function read_score_list() { $scores_arr=array(); $scores_arr["scores"]=array(); $this->conn->connect(); //$theDirectory = opendir($this->mScorePath); // row 0: id // row 1: numero // row 2: nom // row 3: compo // row 4: style $the_directory = scandir($this->score_path); sort($the_directory); foreach ($the_directory as $entry_name) { if (($entry_name != ".") && ($entry_name != "..")) { $query = "SELECT * from repertoire where numero=$entry_name"; $resultat = $this->conn->execute($query); $row = mysql_fetch_row($resultat); $score_item=array( "id" => $row[1], "name" => $row[2], "compositor" => $row[3], "style" => $row[4] ); array_push($scores_arr["scores"], $score_item); } } return $scores_arr; } // read products public function read() { // select all query $query = "SELECT c.name as category_name, p.id, p.name, p.description, p.price, p.category_id, p.created FROM " . $this->table_name . " p LEFT JOIN categories c ON p.category_id = c.id ORDER BY p.created DESC"; // prepare query statement $stmt = $this->conn->prepare($query); // execute query $stmt->execute(); return $stmt; } }