-
- if ($content_type == 'text/plain') {
- header('Content-Disposition: attachment; filename="error.txt"');
- header('Content-type: '. $content_type);
- echo "ERROR: " .$str . "\n";
- exit;
- }
-
- require_once 'Services/JSON.php';
- $json = new Services_JSON();
-
- $retHTML = isset($_SERVER['CONTENT_TYPE']) &&
- preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']);
-
- if ($retHTML){
- if (isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] == 'NO') {
- $retHTML = false;
+ $keys = $x->keys();
+ // var_dump($keys);exit;
+ foreach($q as $key=>$val) {
+
+ if (in_array($key,$keys) && !is_array($val)) {
+
+ $x->$key = $val;
+ }
+
+ // handles name[]=fred&name[]=brian => name in ('fred', 'brian').
+ // value is an array..
+ if (is_array($val) ) {
+
+ $pref = '';
+
+ if ($key[0] == '!') {
+ $pref = '!';
+ $key = substr($key,1);
+ }
+
+ if (!in_array( $key, array_keys($this->cols))) {
+ continue;
+ }
+
+ // support a[0] a[1] ..... => whereAddIn(
+ $ar = array();
+ $quote = false;
+ foreach($val as $k=>$v) {
+ if (!is_numeric($k)) {
+ $ar = array();
+ break;
+ }
+ // FIXME: note this is not typesafe for anything other than mysql..
+
+ if (!is_numeric($v) || !is_long($v)) {
+ $quote = true;
+ }
+ $ar[] = $v;
+
+ }
+ if (count($ar)) {
+
+
+ $x->whereAddIn($pref . (
+ isset($this->colsJname[$key]) ?
+ $this->colsJname[$key] :
+ ($x->tableName(). '.'.$key)),
+ $ar, $quote ? 'string' : 'int');
+ }
+
+ continue;
+ }
+
+
+ // handles !name=fred => name not equal fred.
+ if ($key[0] == '!' && in_array(substr($key, 1), array_keys($this->cols))) {
+
+ $key = substr($key, 1) ;
+
+ $x->whereAdd( (
+ isset($this->colsJname[$key]) ?
+ $this->colsJname[$key] :
+ $x->tableName(). '.'.$key ) . ' != ' .
+ (is_numeric($val) ? $val : "'". $x->escape($val) . "'")
+ );
+ continue;
+