php - Placeholder variable for table name in fetchAll function -


i have function in php uses select sql query. using placeholder variable (?) in query this. (this placeholder table name in mysql database):

protected function _fetchpreviousshiftdata($table, $report_time) {  $query = "select * ? report_date=? , shift=?"; $previousshiftdata = $this->_getdbconnection()->fetchall($query,array($table, date("y-m-d"), $this->_shiftvalue($report_time, 8)));  return $previousshiftdata; } 

but have error in $table variable, how should use "?" $table variable? error this:

php fatal error:  uncaught exception 'pdoexception' message 'sqlstate[42000]: syntax error or access violation: 1064 have error in sql syntax; check manual corresponds mysql server version right syntax use near ''adsl_support' report_date='2013-04-06' , shift='18-2'' @ line 1' in c:\php_shared_lib\zend\db\statement\pdo.php:228 

you can't use table name or fields names... passed values...

you can make list of possibles table names, check , build query

"select `$table`..."  

if check passed


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -