Ticket #31 (closed Feature Request: wontfix)

Opened 16 months ago

Last modified 11 months ago

Active Record does not support parentheses

Reported by: Shadowhand Owned by: zombor
Priority: major Milestone: 2.0
Component: Core Version: SVN HEAD
Keywords: ActiveRecord AR SQL DB Cc:

Description

Active Record should support queries like:

SELECT * FROM `table` WHERE (`foo` = 1 AND `bar` = 5) OR (`foo` = 3 AND `bar` = 7);

Syntax will have to be decided.

Change History

Changed 16 months ago by zombor

I propose this AR code:

$this->db->from('table')->where('a', 1)->where(array('b' => 2, 'c' => 3), 'or')->orwhere('d', 4);

makes:

SELECT * FROM 'table' WHERE `a` = 1 AND (`b` = 2 or `c` = 3) OR `d` = 4;

Changed 16 months ago by zombor

  • status changed from new to assigned

Changed 16 months ago by gregmac

What value is there doing this vs just specifying the WHERE clause in SQL? SQL seems more readable and predicable

Changed 16 months ago by JAAulde

Greg, the value in this is to avoid writing any SQL which really is the is the purpose of Active Record. And avoiding as much manual SQL writing as possible helps prevent injection.

Changed 16 months ago by zombor

  • type changed from bug to enhancement

This is not really a bug, but an enhancement to the current AR syntax, so I'm changing it as such.

Changed 16 months ago by zombor

  • milestone changed from 1.0 to 1.1

Changed 12 months ago by Shadowhand

  • version set to SVN HEAD
  • component set to Kohana Framework
  • milestone changed from 1.1 (Development Stopped) to 2.0

Changed 11 months ago by zombor

  • status changed from assigned to closed
  • resolution set to wontfix
Note: See TracTickets for help on using tickets.