19 include_once (
'Class.Log.php');
36 "lib" =>
"Commence par",
38 "param" =>
"SEMIPERCENT"
46 "lib" =>
"Ne Contient Pas",
51 "lib" =>
"Est égal à",
56 "lib" =>
"Est différent de",
61 "lib" =>
"Est Supérieur à",
66 "lib" =>
"Est Inférieur à",
71 "lib" =>
"N'est pas Vide",
72 "oper" =>
"is not null",
94 $this->log =
new Log(
"",
"Query",
"$class");
96 $this->dbaccess = $this->basic_elem->dbaccess;
100 private function initQuery(
$start = 0,
$slice = 0, $p_query =
"", $onlycont =
false)
103 if ($p_query ==
'') {
107 foreach ($this->basic_elem->fields as $k => $v) {
108 $select =
$select .
" " . $this->basic_elem->dbtable .
"." . $v .
",";
111 foreach ($this->basic_elem->sup_fields as $k => $v) {
119 $from = $this->basic_elem->dbtable;
120 foreach ($this->basic_elem->sup_tables as $k => $v) {
124 $query =
"select {$select}
129 if ($where[$nb_where] !=
"") {
133 if ($where[$nb_where] !=
"") {
137 if ($where[$nb_where] !=
"") {
145 while (list($k, $v) = each($where)) {
157 if (($this->
order_by !=
"") && (!$onlycont)) {
159 if (isset($this->desc) && ($this->desc ==
"up")) {
173 $this->LastQuery =
$query;
184 static $prepare = null;
185 if ($prepare === null) {
186 include_once (
'FDL/freedom_util.php');
187 $err =
simpleQuery(
getDbAccess() ,
"select val from paramv where name='CORE_QUERYPREPARE' and type='G';", $sPrepare,
true,
true);
191 $prepare = ($sPrepare ==
"yes");
210 $this->res_type = $res_type;
214 if ($res_type ==
"ITER") {
216 throw new Exception(
"query fail : " .
$err);
218 include_once (
"Class.DbObjectList.php");
219 return new DbObjectList($this->dbaccess, $this->basic_elem->res, $this->class);
224 $this->nb = $this->basic_elem->numrows();
226 if ($this->nb == 0) {
229 if ($res_type ==
"ITEM") {
231 return $this->basic_elem->res;
233 if (
$start >= $this->nb) {
245 if ($res_type ==
"TABLE") {
246 $this->list = pg_fetch_all($this->basic_elem->res);
249 $result = $this->basic_elem->fetch_array(
$c);
250 if (($res_type ==
"LIST") || ($res_type ==
"LISTC")) {
251 $this->list[
$c] =
new $this->
class(
$this->dbaccess,
"", $result, $this->basic_elem->dbid);
253 while (list($k, $v) = each($result)) {
254 $this->list[
$c][$k] = $v;
259 return ($this->list);
268 $this->res_type =
"TABLE";
273 $result = $this->basic_elem->fetch_array(0);
274 return ($result[
"count"]);
280 if (isset($this->criteria) && ($this->criteria !=
"") && ($this->
operator !=
"none")) {
281 if ($this->casse ==
"NON") {
282 $out =
$out .
" upper(" . $this->criteria .
") " . $this->operators[$this->operator][
"oper"];
284 $out =
$out . $this->criteria .
" " . $this->operators[$this->operator][
"oper"];
287 switch ($this->operators[$this->
operator][
"param"]) {
289 $string =
" {$this->string}";
293 $string =
" '%{$this->string}%'";
297 $string =
" '{$this->string}%'";
299 if (($this->
operator !=
'null') && ($this->
operator !=
'notn')) {
300 if ($this->casse ==
"NON") {
301 $out.=
" upper({$string})";
317 if (
sizeof($this->basic_elem->sup_where) > 0) {
318 reset($this->basic_elem->sup_where);
320 while (list($k, $v) = each($this->basic_elem->sup_where)) {
334 $this->basic_elem->sup_where[] = $contraint;
338 $this->basic_elem->sup_where = array();
343 if ($resultname ==
"") $this->basic_elem->sup_fields[] = $sqlattr;
344 else $this->basic_elem->sup_fields[] =
"$sqlattr as $resultname";