Skip to main content
deleted 25 characters in body; edited title
Source Link
Craige
  • 3.8k
  • 24
  • 30

What are the advantages to using SQL query builders - any advantages?

Example:

https://github.com/jstayton/QueryBuilder

Are there any advantages to using: a query builder, rather than using raw SQL?

$q->select('*')->from('posts')->innerJoin('terms', 'post_id')->where(... E.g.

instead of just doing it the old-fashioned way:

$q->select('*') ->from('posts') ->innerJoin('terms', 'post_id') ->where(...) 

SELECT * FROM posts WHERE ... vs:

?

SELECT * FROM posts WHERE ... 

I see that many frameworks use these kind of abstraction layers, but I fail to understand the benefits :(.

SQL query builders - any advantages?

Example:

https://github.com/jstayton/QueryBuilder

Are there any advantages using:

$q->select('*')->from('posts')->innerJoin('terms', 'post_id')->where(...

instead of just doing it the old-fashioned way:

SELECT * FROM posts WHERE ...

?

I see that many frameworks use these kind of abstraction layers, but I fail to understand the benefits :(

What are the advantages to using SQL query builders?

Are there any advantages to using a query builder, rather than using raw SQL?

E.g.

$q->select('*') ->from('posts') ->innerJoin('terms', 'post_id') ->where(...) 

vs:

SELECT * FROM posts WHERE ... 

I see that many frameworks use these kind of abstraction layers, but I fail to understand the benefits.

Source Link
Anna K.
  • 189
  • 1
  • 1
  • 3

SQL query builders - any advantages?

Example:

https://github.com/jstayton/QueryBuilder

Are there any advantages using:

$q->select('*')->from('posts')->innerJoin('terms', 'post_id')->where(...

instead of just doing it the old-fashioned way:

SELECT * FROM posts WHERE ...

?

I see that many frameworks use these kind of abstraction layers, but I fail to understand the benefits :(