ConstructQuery($sql, $limit, $start); } // request factory // parameters are passed to as '?(name)' public static function Query($sql, $limit = NULL, $start = 0) { self::singleton(); // assure to have an instance return self::$instance->ConstructQuery($sql, $limit, $start); } // automatic parameter substitution, get result public static function QueryResult($sql) { $q = self::Query($sql); $a = func_get_args(); array_shift($a); foreach($a as $n=>&$v) { $q->SetParameter($n, $v); } $r = $q->Execute(); return $r; } // automatic parameter substitution, get result, return value of first row, first column public static function QueryResultValue($sql) { $a = func_get_args(); $r = call_user_func_array(array(__CLASS__, 'QueryResult'), $a); if($r->NumRows() == 0) return NULL; return $r->FetchValue(); } // automatic parameter substitution, get result, return hash of first row public static function QueryResultAssoc($sql) { $a = func_get_args(); $r = call_user_func_array(array(__CLASS__, 'QueryResult'), $a); if($r->NumRows() == 0) return NULL; return $r->FetchAssoc(); } // automatic parameter substitution, get all result rows as a hash public static function QueryAllResultsAssoc($sql) { $a = func_get_args(); $r = call_user_func_array(array(__CLASS__, 'QueryResult'), $a); if($r->NumRows() == 0) return NULL; return $r->FetchAllAssoc(); } // automatic parameter substitution, get all result values as an array public static function QueryAllResultValues($sql) { $a = func_get_args(); $r = call_user_func_array(array(__CLASS__, 'QueryResult'), $a); if($r->NumRows() == 0) return NULL; return $r->FetchAllValues(); } // automatic parameter substitution, get affected rows public static function UpdateQuery($sql) { $a = func_get_args(); $r = call_user_func_array(array(__CLASS__, 'QueryResult'), $a); return $r->AffectedRows(); } // automatic parameter substitution, get insert id public static function InsertQuery($sql) { $a = func_get_args(); $r = call_user_func_array(array(__CLASS__, 'QueryResult'), $a); if (is_null($r->AffectedRows())) return NULL; return $r->InsertId(); } } ?>