Pop\Db\Record\Prepared::findAll PHP Метод

findAll() публичный Метод

Find all of the database rows by the column passed through the method argument.
public findAll ( string $order = null, array $columns = null, integer $limit = null, integer $offset = null ) : void
$order string
$columns array
$limit integer
$offset integer
Результат void
    public function findAll($order = null, array $columns = null, $limit = null, $offset = null)
    {
        // Build the SQL.
        $this->sql->select();
        // If a specific column and value are passed.
        if (null !== $columns) {
            $this->finder = array_merge($this->finder, $columns);
            $i = 1;
            foreach ($columns as $key => $value) {
                if (strpos($value, '%') !== false) {
                    $this->sql->select()->where()->like($key, $this->getPlaceholder($key, $i));
                    $i++;
                } else {
                    if (null === $value) {
                        $this->sql->select()->where()->isNull($key);
                    } else {
                        $this->sql->select()->where()->equalTo($key, $this->getPlaceholder($key, $i));
                        $i++;
                    }
                }
            }
        } else {
            $this->finder = array();
        }
        // Set any limit to the SQL query.
        if (null !== $limit) {
            $this->sql->select()->limit($this->sql->adapter()->escape($limit));
        }
        // Set the offset, if passed
        if (null !== $offset) {
            $this->sql->select()->offset($this->sql->adapter()->escape($offset));
        }
        // Set the SQL query to a specific order, if given.
        if (null !== $order) {
            $ord = $this->getOrder($order);
            $this->sql->select()->orderBy($ord['by'], $this->sql->adapter()->escape($ord['order']));
        }
        // Prepare the SQL statement
        $this->sql->adapter()->prepare($this->sql->render(true));
        // Bind the parameters
        if (null !== $columns) {
            $params = array();
            foreach ($columns as $key => $value) {
                if (null !== $value) {
                    $params[$key] = $value;
                }
            }
            $this->sql->adapter()->bindParams($params);
        }
        // Execute the statement and set the return results.
        $this->sql->adapter()->execute();
        $this->setResults();
    }