Beispiel #1
0
 public function prepareValue($value)
 {
     if (is_bool($value)) {
         return $value ? 1 : 0;
     } elseif (is_int($value)) {
         return $value;
     } elseif (is_float($value)) {
         // convert the decimal separator back to english notation if changed by locale
         $localeconv = localeconv();
         return str_replace($localeconv['decimal_point'], '.', $value);
     } elseif (is_string($value)) {
         return "'" . $this->escapeString($value) . "'";
     } elseif ($value === null) {
         return 'NULL';
     } elseif ($value instanceof SisField) {
         return $value->getFullName();
     } else {
         Sis::error('Invalid data type!', array('value' => $value));
         return false;
     }
 }
Beispiel #2
0
 public function getRowOp()
 {
     $op = Sis::op($this::TABLE);
     if ($this->id !== null) {
         $op->eq($this::ID_FIELD, $this->id);
     } else {
         trigger_error('Cannot create row op: Object has no ID', E_USER_ERROR);
     }
     if ($this->customFields !== null) {
         call_user_func(array($op, 'fields'), implode(', ', $this->customFields));
     }
     return $op;
 }
Beispiel #3
0
 public function __construct($type, $op, $params)
 {
     if (!self::isValid($type)) {
         Sis::error('Invalid condition type!', array('type' => $type));
     }
     $this->type = self::resolveAliases($type);
     $this->op = $op;
     $this->params = $params;
     // Operations starting with "field" accept an array shorthand for
     // operating on multiple fields.
     if (substr($this->type, 0, 6) == 'field_' && is_array($params[0])) {
         $subConds = array();
         foreach ($params[0] as $fieldName => $value) {
             $subConds[] = new self($this->type, $op, array($fieldName, $value));
         }
         $this->type = 'merge_and';
         $this->op = $op;
         $this->params = $subConds;
         // This is an optimization - we skip prepare_merge_and because
         // we already know our subconditions are not registered with
         // the operation object.
         return;
     }
     // some conditions need preparation
     $method = 'prepare_' . $this->type;
     if (method_exists(__CLASS__, $method)) {
         self::$method($this->op, $this->params);
     }
 }