1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
<?php
class SortableExampleGallery {
public function __construct() {
if ( file_exists('../config.php') ){include('../config.php');}
$this->conn = mysql_connect($host, $username, $password);
mysql_select_db($database,$this->conn);
}
public function getList() {
if ( file_exists('../config.php') ){include('../config.php');}
//$sql = "SELECT kuvat.name as image, min(kuvat.jarjestys), galleriat.* FROM kuvat, galleriat where kuvat.galleria = galleriat.id having min(kuvat.jarjestys) order by jarjestys";
//$sql = "SELECT kuvat.name as image, min(kuvat.jarjestys), galleriat.* FROM kuvat, galleriat where kuvat.galleria = galleriat.id group by kuvat.galleria order by jarjestys";
//SELECT kuvat.name as image, galleriat.* FROM galleriat, kuvat where kuvat.galleria = galleriat.id and having min(kuvat.jarjestys)
//TODO: ylemmät palauttaa jostain syystä vain ne joissa on jo yksi kuva
$sql = "select galleriat.* from galleriat order by jarjestys";
$recordSet = mysql_query($sql,$this->conn);
$results = array();
while($row = mysql_fetch_assoc($recordSet)) {
$results[] = $row;
}
return $results;
}
public function updateList($orderArray) {
if ( file_exists('../config.php') ){include('../config.php');}
$orderid = 1;
foreach($orderArray as $catid) {
$catid = (int) $catid;
$sql = "UPDATE galleriat SET jarjestys={$orderid} WHERE id=" . $catid;
$recordSet = mysql_query($sql,$this->conn);
$orderid++;
}
}
}
?> |
Partager