Jump to content
Larry Ullman's Book Forums

Can We Pass Dynamically Table Names Using Prepared Statements?


Recommended Posts

Passing it like a variable it means something like this:

 

q = 'SELECT email FROM ' . $tableName . ' WHERE id=? LIMIT 1';

 

When you make a function or create a class to work with the database it make sense to have the table passed dynamically. Certainly, I was looking for something parameter wise, I just wanted to be sure I do not miss something. Thank you for your help.

Link to comment
Share on other sites

I knew what you meant, and I was suggesting something like populating an array with the names of the tables, and then looping through the array, making a new prepared statement for each table. After that, you could access any table using prepared statements.

Link to comment
Share on other sites

 Share

×
×
  • Create New...