0
abstract class RepositoryBase
{
    protected $connection;//This is PDO Object!

    public function __construct(PDO $connection = null)
    {
        $this->connection = $connection;
        if ($this->connection === null) {
            $this->connection = new PDO(
                'mysql:host=localhost:3307;dbname=project',
                'root',
                'usbw'
            );
            $this->connection->setAttribute(
                PDO::ATTR_ERRMODE,
                PDO::ERRMODE_EXCEPTION
            );
        }
    }

pdo set names utf8 <-- how can i do it

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Gakki
  • 23
  • 7
  • You'll find your answer in http://php.net/manual/en/pdo.construct.php and http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Funk Forty Niner Mar 15 '17 at 14:54

1 Answers1

-1

Try this:

$options = [
    PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
];

$this->connection = new PDO(
    'mysql:host=localhost:3307;dbname=project',
    'root',
    'usbw',
    $options
);

$this->connection->setAttribute(
    PDO::ATTR_ERRMODE,
    PDO::ERRMODE_EXCEPTION
);
Andre Cardoso
  • 228
  • 1
  • 12