zend-db icon indicating copy to clipboard operation
zend-db copied to clipboard

Allow Invokable Objects For `$where` parameters in AbstractTableGateway

Open baileylo opened this issue 7 years ago • 1 comments

Currently, the $where parameter in AbstractTableGateway::select, AbstractTableGateway::update, and AbstractTableGateway::delete will accept Closures, but not invokable classes. It would be nice if it were possible expand the allowed parameters types to include invokable classes.

The following code should allow it. I was hoping to replace with is_callable($where), but that would return true for cases where $where couldn't be executed using $where($select);, e..g [ new\DateTime, 'format'].

if ($where instanceof \Closure || (is_object($where) && is_callable($where))) {
    $where($select);
} elseif ($where !== null) {
    $select->where($where);
}

baileylo avatar Oct 05 '17 20:10 baileylo

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at https://github.com/laminas/laminas-db/issues/63.

michalbundyra avatar Jan 16 '20 19:01 michalbundyra