Suppose I have a table:
$someTable = new Zend_Db_Table ('sometable');
I know I can build a query using the table's literal name.
$sel = $someTable -> select ()
-> from ('sometable', array ('col_foo', 'col_bar'))
-> where ('some_condition')
and that I can alias the table.
$sel = $someTable -> select ()
-> from (array ('alias' => 'sometable'), array ('col_foo', 'col_bar'))
-> where ('some_condition')
I also know I can use the Zend_Db_Table directly in the from() call:
$sel = $someTable -> select ()
-> from ($someTable, array ('col_foo', 'col_bar'))
-> where ('some_condition')
but when I try aliasing the table object like below, I get a fatal error.
$sel = $someTable -> select ()
-> from (array ('alias' => $someTable), array ('col_foo', 'col_bar'))
-> where ('some_condition')
Catchable fatal error: Object of class Zend_Db_Table could not be converted to string in ...
It seems to me that this is buggy behavior because the from(), join(), etc methods can handle having a Zend_Db_Table object passed to them, but not when you want to alias it!
The example above is a little contrived and simplified to illustrate the problem. The real code is doing joins between tables but as the table objects are being passed in I don't know what their names are ahead of time. Of course I can work around the above problem using info() to get the table names and inject them as strings, but this means extra code which to me looks messy. Besides, this is a circumstance that Zend_Db should be able to cope with without such workarounds.
I'm using Zend Framework 1.7.6. and am subclassing Zend_Db_Table_Abstract to make my table objects. Unfortunately I don't have the authority to get an upgraded version of Zend installed.