-
Notifications
You must be signed in to change notification settings - Fork 2.5k
ZF2.4 Breaks 'Count' via \Zend\Db\Sql\Expression on IBM i & DB2 #7400
Comments
I and @kingharrison tried in ZF 2.3 and worked, but not work in 2.4 |
Can you post the complete error message including class/file/line, because there is no |
Excuse my newb-ness, but I assume this is what you mean: 16 Zend\Paginator\Adapter\DbSelect::getSelectCount() /usr/local/zendsvr6/var/libraries/Zend_Framework_2/2.4.0/library/Zend/Paginator/Adapter/DbSelect.php:149 |
@kingharrison can you give code from |
The stack trace is helpful, but the message |
Here is where I call paginator in Suppliers\Controller\SupplierMaintenanceController::indexAction()
Here is fetchAllSuppliers from my TableGateway: This does work when I turn the system version back to 2.3.7 |
@Martin-P I think this is what you needed: This line, 149, seems to be the issue. |
For possible reference things work a bit different in DB2. There are no LIMIT or OFFSET commands, so to get paginator working originally they had to adjust some code. Here is my original reported issue on pagination and DB2 which did get fixed: |
@kingharrison Please download again ZF 2.4.0. Seems you have a modified version of DbSelect.php |
No, sorry, that is not the info. The error message you will see, is this (where [filename] and [line number] contain the crucial info):
The message you post looks like some 3rd party plugin which messes up the actual error message. Please deativate it and post the real message. You could also look for it in the PHP error log. |
@Martin-P "3rd party plugin" in the log - this is only controller. Or not? |
I am using ZRay to help debug it. This is from my php log access through Zend Server. Here is my trying to run it a couple times in a row. [01-Apr-2015 20:35:32 America/Phoenix] PHP Fatal error: Undefined class constant 'self::TYPE_SELECT' in /usr/local/zendsvr6/var/libraries/Zend_Framework_2/2.4.0/library/Zend/Paginator/Adapter/DbSelect.php on line 149 |
@Maks3w I used the updater in Zend Server. Besides redeploying how do I download a standard version? Is there a place I can download the ZPK and deploy it that way? IBM i boxes are locked down pretty tight so I would need to deploy through Zend Server. |
I think it has to do with the count function. I found another page throwing the error that was not pagination. This line of code: In something I called AgendaTable was producing this error: That line was on line 20. Count seems to be broken on DB2? |
This shows the error is not in ZF2, but in |
Here is the entire file (again this all works without error in ZF 2.3.7): <?php
namespace K3sbase\Table;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql\Select;
class AgendaTable {
protected $tableGateway;
public function __construct(TableGateway $tableGateway) {
$this->tableGateway = $tableGateway;
}
public function agendaTotalCount($data) {
$rowset = $this->tableGateway->select ( function (Select $select) use($data) {
$select->where ( $data )->columns ( array (
'COUNT' => new \Zend\Db\Sql\Expression ( 'COUNT(SO_SOQTYPE)' ) //This is line 20 throwing the error.
) );
$select->where->nest->equalTo ( 'SO_SOQTYPE', 'ND' )->or->equalTo ( 'SO_SOQTYPE', 'FB' )->or->equalTo ( 'SO_SOQTYPE', 'FR' )->or->equalTo ( 'SO_SOQTYPE', 'RE' )->or->equalTo ( 'SO_SOQTYPE', 'FC' )->or->equalTo ( 'SO_SOQTYPE', 'SO' )->unnest->and->where->notEqualTo ( 'SO_USERA1', '0' );
} );
$entities = array ();
foreach ( $rowset as $row ) {
$entity = array (
"count" => $row->COUNT
);
$entities [] = $entity;
}
return $entities;
}
} |
As pagination uses Count as well this would make sense that pagination breaks. Should I change the title of this issue? It seems to be Count on the IBM i that breaks. |
The strange thing here is you get an error about
What if you use |
If I change it to COUNT(1) as in Zend\Paginator\Adapter\DbSelect it still produces the same error. |
To make sure of something, can you turn down or off the optimization level for zend optimizer and try to load that page again after a restart? |
@ralphschindler I turned of Zend OpCache completely and tried and got the same error. |
I've just grepped through ZF 2.4.0. The constant
Line 149 of $countSelect->columns(array(self::ROW_COUNT_COLUMN_NAME => new Expression('COUNT(1)'))); This operation ( In other words, stepping through the code invoked, I am at a loss as to how that would even reference the given constant, much less fail a lookup on it. My gut tells me there's a code caching issue somehow, and that you're getting old code and/or a mix of old and new code which conflict. You indicated that you're using the Zend Server library support; IIRC, we have some functionality in the bootstrap to ensure you get the latest version from that, but perhaps you could send that code? I would need to see the files |
I assume this is where you want me to post @weierophinney init_autoloader.php $zf2Path = false; if (is_dir('vendor/ZF2/library')) { if ($zf2Path) { if (!class_exists('Zend\Loader\AutoloaderFactory')) { public/index.php chdir(dirname(DIR)); // This was added for the EdpSuperluminal module. This creates ultra fastness feelings inside. // Decline static file requests back to the PHP built-in webserver // Setup autoloading // Run the application! |
@kingharrison I though it because of the EdpSuperLuminal, could you turn off the EdpSuperluminal ( commented the ) : define('ZF_CLASS_CACHE', 'data/cache/classes.php.cache'); if (file_exists(ZF_CLASS_CACHE)) require_once ZF_CLASS_CACHE; ? |
@weierophinney @samsonasik |
@kingharrison awesome ;), please close it then ;). sorry for can't solve it yesterday and direct you here ;) |
When trying to use the paginator adapter an error is returned:
Undefined class constant 'self::TYPE_SELECT'
This originates from Zend/Paginator/Adapter/DbSelect.php line 149 which is:
$countSelect->columns(array(self::ROW_COUNT_COLUMN_NAME => new Expression('COUNT(1)')));
The text was updated successfully, but these errors were encountered: