What is the benefit of placing the database name in a SQL statement for PDO? (IE: UPDATE database.table)
-
I'm wondering because I'm re-working some code and noticed that my database calls reference the table as "database.table" in the string. I have a constant defined with the database name, but for some reason I didn't concatenate it into my database calls (I just use it to establish the connection). Would you concatenate the database call with this constant, or do you feel that might present issues with SQL injection?
-
Answer:
If you have multiple databases running on the same server, and your user credentials allow access to both, you can access different databases in the same connection, do joins across them, etc. SELECT tableA.id, tableB.name FROM db1.tableA JOIN db2.tableB ON (...) If your app was accessing multiple databases, I would use that convention across the code to make it clear which database any given table is in. If you're only ever accessing a single database on the server instance, I don't know of any advantage of prepending the database name.
Jon Moter at Quora Visit the source
Related Q & A:
- What is the best practice for free space for a SQL server database drive?Best solution by Database Administrators
- How to restrict access to a sql server database from Azure?Best solution by Stack Overflow
- How do I connect to a SQL Server database?Best solution by Stack Overflow
- What is the benefit of being a surgeon?
- What exactly is a thesis statement?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.