valency Posted July 17, 2008 Share Posted July 17, 2008 Can someone help interpret this for me: function totalNumof Invoices() { $sql = 'SELECT count(id) as total FROM '.$this->dbconnect->getTablePrefix().'invoices '.$where; $rsx = $this->dbconnect->querySelect($sql); } how does a query like this work exactly? seems like old php version to me...help explain the getTablePrefix().'invoices '.$where part.... the only thing declared in this frankinstein code is this: function Invoices() { $this->dbconnect->setTablePrefix($tp); $tableprefix = $tp; } Quote Link to comment Share on other sites More sharing options...
gizmola Posted July 19, 2008 Share Posted July 19, 2008 The purpose of the tableprefix looks to be allowing for mutliple versions of the tables in question to be able to coexist, via the "tableprefix" variable. This has to have been saved somewhere and is probably brought in via a config or ini file. So when the db was created, rather than have an "invoices" table in the database, the table is actually names 'myinvoices' (assuming that the value returned by the getTablePrefix() method was "my". All that's happening is basic concatention of a string to create the SQL statement that is ultimately being executed. The $where variable seems to be a global, or it must not be working, so I'd agree if that's true that the design of this isn't the best, as relying on globals is a pretty poor practice. However, this observation is based on your snippet, and if you omitted things it might not be relevant. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.