0

I'm looking for a php lib that allows me to compile sql strings in a oop way, for example

$select->fromTable = 'test'
$select->addWhere('field', '>=', 33);
$select->groupBy...

something like this, just an example

1 Answers1

1

For basic, lightweight query building, I found this: http://www.phpclasses.org/package/2813-PHP-Dynamically-build-SQL-queries.html

There are some implementations of ActiveRecord pattern for PHP, for example http://www.propelorm.org/ and http://www.phpactiverecord.org/. Don't know if that's what you need, but they both look nice. They allow you to bypass SQL completely and just use generated finder methods on your domain objects.

Also look at this thread: SQL Builder for PHP, with JOIN support? Recommendations there center on web frameworks, though, and adding them to a project in late stage can be difficult.

Community
  • 1
  • 1
socha23
  • 10,171
  • 2
  • 28
  • 25
  • excellent, but seems too "high level", I just need some "sql composer"... If i don't get some better answer I will accept this, thank you in the meantime! –  Nov 03 '11 at 09:34
  • I've updated my answer, take a look at first link. I think it may be what you seek. – socha23 Nov 03 '11 at 09:39