static function GetItems Select Table Start Limit Join Conditions Opti

 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
static function GetItems($Select, $Table, $Start, $Limit, $Join, $Conditions, $Optional = null)
{
global $DatabaseConnection;
$Items = array();
$Code = "SELECT ".$Select." FROM ".$Table;
if(is_array($Join)
{
foreach($Join as $Table)
{
$Code .= " JOIN ".$Table[0]." ON";
foreach($Table[1] as $From => $To)
{
$Code .= " ".$From." = ".$To."";
}
}
}
if(!empty($Conditions) && is_array($Conditions) && count($Conditions))
{
$Code .= " WHERE ";
}
$QueryCode .= $Optional;
if($Limit !== FALSE)
{
$QueryCode .= " LIMIT ".$Start.",".$Limit;
}
echo "<hr><b><img src=\"images/modules/forward.png\" border=\"0\"> ".$QueryCode."</b><hr>\n";
if($Query = $DatabaseConnection->Query($QueryCode))
{
return $Query->FetchAll(PDO::FETCH_ASSOC);
} else {
print_r($DatabaseConnection->errorInfo());
return FALSE;
}
}