AddressFinder.php 618 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
<?php

namespace LQDN\Finder;

use Doctrine\DBAL\Connection;

class AddressFinder
{
    private $connection;

    public function __construct(Connection $connection)
    {
        $this->connection = $connection;
    }

    /**
     * Return all adresses of a given user.
     *
     * @param mixed $userId
     *
     * @return array
     */
    public function findByUserId($userId)
    {
        $userId = (int) $userId;
        $stmt = $this->connection->executeQuery('SELECT * FROM adresses WHERE user_id = :user_id', ['user_id' => $userId]);
27 28
        $addresse = $stmt->fetch();
        return $addresse;
29 30
    }
}