コード例 #1
0
 function criteria_my_preferred($element)
 {
     $field = $this->put_alias($element['real_field']);
     $criteria = phpgwapi_sql_criteria::or_(phpgwapi_sql_criteria::equal($field, phpgwapi_sql::string($element['value'])), phpgwapi_sql_criteria::is_null($field));
     $this->_add_criteria($criteria);
     return $criteria;
 }
コード例 #2
0
 function criteria_comm_find_descr($element)
 {
     $field = $this->put_alias($element['real_field']);
     foreach ($element['value'] as $value) {
         $data[] = phpgwapi_sql_criteria::equal($field, phpgwapi_sql::string($value));
     }
     $criteria = phpgwapi_sql_criteria::append_or($data);
     $this->_add_criteria($criteria);
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
 /**
  * Allow to change the current cat_id by the new
  *
  * @param integer $cid The contact_id what you want to edit
  * @param array $categories The new categories
  * @param $action
  * @return string SQL update string
  */
 function edit_category($cid, $categories = array(), $action = PHPGW_SQL_RETURN_SQL)
 {
     $contact = createObject('phpgwapi.contact_central');
     $principal['cat_id'] = $this->get_categories($categories);
     return $contact->update($principal, phpgwapi_sql_criteria::_equal('contact_id', phpgwapi_sql::integer($cid)), $action);
 }
コード例 #5
0
 public static function str_time2int($time)
 {
     return (int) phpgwapi_sql::str_date2int($time);
 }
コード例 #6
0
 /**
  * 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}";
 }
コード例 #7
0
 function criteria_sel_cat_id($element)
 {
     $field = $this->put_alias($element['real_field']);
     if (is_array($element['value'])) {
         foreach ($element['value'] as $value) {
             $data[] = phpgwapi_sql_criteria::or_(phpgwapi_sql_criteria::equal($field, sql::string($value)), phpgwapi_sql_criteria::has($field, ',' . $value . ','));
         }
         $criteria = phpgwapi_sql_criteria::append_or($data);
         $this->_add_criteria($criteria);
     } else {
         $this->_add_criteria(phpgwapi_sql_criteria::equal($field, phpgwapi_sql::string($element['value'])));
     }
 }
コード例 #8
0
 function full_name()
 {
     $this->add_field('per_full_name', phpgwapi_sql::concat_null(array($this->real_field('per_prefix'), phpgwapi_sql::string(' '), $this->real_field('per_first_name'), phpgwapi_sql::string(' '), $this->real_field('per_middle_name'), phpgwapi_sql::string(' '), $this->real_field('per_last_name'), phpgwapi_sql::string(' '), $this->real_field('per_suffix'))));
 }