/** * Generate a criteria stirng suitable for SQL queries, update and delete. * * @param array $tokens array Multidimensional array created with calls to sql_criteria class methods * @return string Return a criteria string based on tokens */ public static function criteria($tokens) { $operator = array_pop($tokens); if ($operator == 'append_or' || $operator == 'append_and') { return self::$operator($tokens); } $operand_left = array_shift($tokens); // Recursivity if array $operand_left = is_array($operand_left) ? self::criteria($operand_left) : $operand_left; if (count($tokens) > 0) { $operand_right = array_shift($tokens); // Recursivity if array too $operand_right = is_array($operand_right) ? self::criteria($operand_right) : $operand_right; } else { $operand_right = phpgwapi_sql::null(); } return self::$operator($operand_left, $operand_right); }
/** * Genarete a string with field = value to use in update * * @param string $fields * @param string $values * @return string with field=value list. */ function set_update_data($element) { if ($element['value'] || $element['value'] == 0) { $value = $this->cast($element['value'], $element['field']); } else { phpgwapi_sql::null(); } if ($this->values) { $this->values .= ', '; } $this->values .= "{$element['real_field']} = {$value}"; }