Zend Framework

Using Zend_Db_Table_Select objects with Zend_Paginator throws exception "No table has been specified for the FROM clause"

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 1.6.0RC1
  • Fix Version/s: None
  • Component/s: Zend_Paginator
  • Labels:
    None

Description

Instances of Zend_Db_Table_Select do not work with Zend_Paginator unless you specify a from clause (which is redundant for Zend_Db_Table_Select).

<?php

// Does not work
$table = new MyTable();
$select = $table->select();
$paginator = Zend_Paginator::factory($select); // Throws exception "No table has been specified for the FROM clause"

// This works
$table = new MyTable();
$select = $table->select()
->from($table); // Required by Zend_Paginator
$paginator = Zend_Paginator::factory($select); // Works

?>

Issue Links

Activity

Hide
Stephen Crosby added a comment -

Paginate can't use a Zend_Db_Table_Select until that object knows which table its supposed to use. This is actually a duplicate of <a href="http://framework.zend.com/issues/browse/ZF-3239">http://framework.zend.com/issues/browse/ZF-3239</a>.

=Doesn't work=
$player = new Player();
$select = $player->select()->order('lastname DESC'); //object still doesn't know what table its going to use
$paginator = Zend_Paginator::factory($select);

=Works=
$player = new Player();
$select = $player->select()->order('lastname DESC');
$select->__toString(); //hack to force the object to set its table!
$paginator = Zend_Paginator::factory($select);

Show
Stephen Crosby added a comment - Paginate can't use a Zend_Db_Table_Select until that object knows which table its supposed to use. This is actually a duplicate of <a href="http://framework.zend.com/issues/browse/ZF-3239">http://framework.zend.com/issues/browse/ZF-3239</a>. =Doesn't work= $player = new Player(); $select = $player->select()->order('lastname DESC'); //object still doesn't know what table its going to use $paginator = Zend_Paginator::factory($select); =Works= $player = new Player(); $select = $player->select()->order('lastname DESC'); $select->__toString(); //hack to force the object to set its table! $paginator = Zend_Paginator::factory($select);
Hide
Stephen Crosby added a comment -

Duplicate issue

Show
Stephen Crosby added a comment - Duplicate issue
Hide
Ralph Schindler added a comment -

Since 1.9 there has been a feature in place that allowed select() to be called on a table with that will load the from part into the object.

Please see here, and the api doc here

I think it might fix this problem.

-ralph

Show
Ralph Schindler added a comment - Since 1.9 there has been a feature in place that allowed select() to be called on a table with that will load the from part into the object. Please see here, and the api doc here I think it might fix this problem. -ralph

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: