Dynamic SQL queries in code possible?
Posted
by
SeanD
on Stack Overflow
See other posts from Stack Overflow
or by SeanD
Published on 2011-01-16T05:47:16Z
Indexed on
2011/01/16
5:54 UTC
Read the original article
Hit count: 182
Instead of hard coding sql queries like Select * from users where user_id =220202
can these be made dynamic like Select * from $users where $user_id = $input.
Reason i ask is when changes are needed to table/column names i can just update it in one place and don't have to ask developers to go line by line to find all references to update. It is very time consuming. And I do not like the idea of exposing database stuff in the code.
My major concern is load time. Like with dynamic pages, the database has to fetch the page content, same way if queries are dynamic first system has to lookup the references then execute the queries, so does it impact load times?
I am using codeignitor PHP.
If it it possible then the next question is where to store all the references? In the app, in a file, in the DB, and how?
© Stack Overflow or respective owner