$sql = "{$sql} LIMIT {$i},{$l}"; //exit("<option>$sql</option>"); //exit($sql); if (count($colArr) > 1) { $col1 = $colArr[1]; } else { $col1 = $colArr[0]; } dispatchData($sql, array('label' => $col, 'value' => $col1), $sys); } elseif ($src == "db") { $where = explode(",", $_REQUEST["where"]); $qW = ""; $i = 0; foreach ($where as $a => $b) { $e = explode(":", $b); $qW .= getRelation($e[1], $e[0], $e[2]); if ($i < sizeOf($where) - 1) { $qW .= " AND "; } $i++; } $_REQUEST["where"] = $qW; $q = generateSelectFromArray($_REQUEST, array("table" => "tbl")); $result = _dbQuery($q); dispatchData(_db()->fetchAllData($result, "array")); _db()->freeResult($result); } exit; function dispatchData($sql, $cols, $sys = false) { $format = "json";
function parseSQLWhere($where) { if (!is_array($whr)) { $wA = explode(",", $where); } else { $wA = $where; } foreach ($wA as $a1 => $a2) { $a3 = preg_split("/(:[a-zA-Z0-9]+:)/", $a2, -1, PREG_SPLIT_DELIM_CAPTURE); if (!isset($a3[2]) || $a3[2] == null || $a3[2] == "") { $wA[$a1] = "({$a3[0]} IS NULL OR {$a3[0]}='') "; continue; } elseif ($a3[2][0] == "@") { $a3[2] = _replace("#" . substr($a3[2], 1) . "#"); } $wA[$a1] = getRelation(substr($a3[1], 1, strlen($a3[1]) - 2), $a3[0], $a3[2]); } $where = implode(" AND ", $wA); return $where; }