Skip to content
This repository has been archived by the owner on May 1, 2019. It is now read-only.

Commit

Permalink
Enhancement: Introduce temporary variable
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Feb 18, 2015
1 parent 5bc495e commit 4be0604
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions module/ZfModule/src/ZfModule/Mapper/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public function pagination($page, $limit, $query = null, $orderBy = null, $sort
}

if (null !== $query) {
$spec = function ($where) use ($query) {
$select->where(function ($where) use ($query) {
/* @var Sql\Where $where */
$where->like('name', '%' . $query . '%')->or->like('description', '%' . $query . '%');
};
$select->where($spec);
$like = '%' . $query . '%';

$where->like('name', $like)->or->like('description', $like);
});
}
$resultSet = new HydratingResultSet($this->getHydrator(), $this->getEntityPrototype());

Expand Down Expand Up @@ -79,11 +80,12 @@ public function findByLike($query, $limit = null, $orderBy = null, $sort = 'ASC'
$select->limit($limit);
}

$spec = function ($where) use ($query) {
$select->where(function ($where) use ($query) {
$like = '%' . $query . '%';

/* @var Sql\Where $where */
$where->like('name', '%' . $query . '%')->or->like('description', '%' . $query . '%');
};
$select->where($spec);
$where->like('name', $like)->or->like('description', $like);
});

$entity = $this->select($select);

Expand Down

0 comments on commit 4be0604

Please sign in to comment.