Exemplo n.º 1
0
 public function builder_call_where_in_scope(Database_Query_Builder $builder, Jam_Event_Data $data, Jam_Model $model)
 {
     if ($this->_scope) {
         foreach ((array) $this->_scope as $scope_field) {
             $builder->where($scope_field, '=', $model->{$scope_field});
         }
     }
 }
Exemplo n.º 2
0
 public function builder_call_visible(Database_Query_Builder $query, Jam_Event_Data $data, $is_visible = TRUE)
 {
     $query->where('is_hidden', '=', !$is_visible);
 }
Exemplo n.º 3
0
 /**
  * Applies WHERE conditions to a query.
  *
  *     // Create a new SELECT query
  *     $query = DB::select();
  *
  *     // Apply model conditions
  *     $model->query_conditions($query);
  *
  * @param   object  query builder
  * @return  object
  */
 public function query_conditions(Database_Query_Builder $query)
 {
     // Import meta data
     $meta = static::meta($this);
     foreach ($meta->fields as $name => $field) {
         if (array_key_exists($name, $this->__changed)) {
             $query->where($meta->column($name), '=', $this->__changed[$name]);
         } elseif ($field->unique and $this->__data[$name]) {
             $query->where($meta->column($name), '=', $this->__data[$name]);
         }
     }
     return $query;
 }
Exemplo n.º 4
0
 /**
  * Apply std builder conditions
  *
  * @param    Database_Query_Builder  $builder   Instance of builder
  */
 private function _position_apply_builder_conditions($field, $builder)
 {
     $config = $this->_position_fields[$field];
     $model = $this->_orm;
     foreach ($config['group_by'] as $gb_field) {
         $builder->where($gb_field, '=', $model->{$gb_field});
     }
     $deleted_field = $this->deleted_field();
     if (array_key_exists($deleted_field, $model->table_columns())) {
         $builder->where($deleted_field, '=', 0);
     }
 }