Example #1
0
 protected function parse_array_terms($terms_list)
 {
     $out = array();
     $logic = 'AND';
     $bind = array();
     foreach ($terms_list as $t) {
         if (SkinnyUtil::ref($t) == 'SCALAR') {
             if (preg_match('-?/OR|AND|OR_NOT|AND_NOT)$/', strtoupper($t), $m)) {
                 $logic = $m[1];
             }
             $logic = strtr($logic, '_', ' ');
             continue;
         }
         $out1 = '';
         if (SkinnyUtil::ref($t) == 'HASH') {
             $out2 = array();
             foreach (array_keys($t) as $t2) {
                 list($term, $bind2, $col) = $this->mk_term($t2, $t[$t2]);
                 $this->where_values[$col] = $t[$t2];
                 $out2[] = $term;
                 $bind[] = $bind2;
             }
             $out1 .= '(' . join(' AND ', $out2) . ')';
         } else {
             if (SkinnyUtil::ref($t) == 'ARRAY') {
                 list($where, $bind2) = $this->parse_array_terms($t);
                 $bind[] = $bind2;
                 $out1 = '(' . $where . ')';
             }
         }
         $out[] = ($out ? ' ' . $logic . ' ' : '') . $out1;
     }
     return array(join('', $out), $bind);
 }
Example #2
0
 function mixin($include)
 {
     if (SkinnyUtil::ref($include) != 'ARRAY') {
         $include = array($include);
     }
     foreach ($include as $class) {
         if (is_array($class)) {
             list($class, $args) = each($class);
             $obj = new $class($this, $args);
         } else {
             $obj = is_object($class) ? $class : new $class($this);
         }
         $methods = $obj->register_method();
         foreach ($methods as $method => $callback) {
             if (is_callable($callback)) {
                 $this->mixins[$method] = $callback;
             } else {
                 trigger_error("could not register '{$method}'. " . 'must be a valid callback.', E_USER_WARNING);
             }
         }
     }
 }
Example #3
0
 function no_cache()
 {
     SkinnyUtil::deprecated('$itr->cache = false');
     $this->cache = false;
     return $this;
 }