示例#1
0
 public function buildWhere(&$isWhereString, &$whereBindParams, &$where)
 {
     //$isWhereString
     //$where
     $whereString = '';
     if ($isWhereString) {
         $whereString .= 'WHERE';
         $whereParamTypes =& $whereBindParams[0];
         //first param passed to bind_param('ssii', ..)
         $i = 0;
         foreach ($where as $k => $item) {
             //	SERVER::dump($item);
             $fieldName = '';
             //append fieldtype (s,i...) to first element of array
             $whereParamTypes .= DBi::SplitField($item['field'], $fieldName);
             //'s:username' return and remove type from field
             //-------------------------------------------
             //allow arrays of values to be passed
             if (is_array($where[$k]['value']) and false) {
                 //needs more testing
                 $where[$k]['value'] = join(', ', $where[$k]['value']);
                 $operator = 'IN';
                 $opTemplate = '(?)';
             } else {
                 $operator = isset($item['operator']) ? $item['operator'] : '=';
                 $opTemplate = '?';
             }
             //-------------------------------------------
             //append field to bind array
             $whereBindParams[] =& $where[$k]['value'];
             $condition = $i == 0 ? '' : ' ' . $item['condition'];
             // first condition following WHERE not needed
             $whereString .= $condition . ' ' . $fieldName . ' ' . $operator . ' ' . $opTemplate;
             $i++;
         }
     }
     return $whereString;
 }