1 | <?php |
||
34 | class MysqlSessionInit implements EventSubscriber |
||
35 | { |
||
36 | /** |
||
37 | * The charset. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | private $_charset; |
||
42 | |||
43 | /** |
||
44 | * The collation, or FALSE if no collation. |
||
45 | * |
||
46 | * @var string|boolean |
||
47 | */ |
||
48 | private $_collation; |
||
49 | |||
50 | /** |
||
51 | * Configure Charset and Collation options of MySQL Client for each Connection. |
||
52 | * |
||
53 | * @param string $charset The charset. |
||
54 | * @param string|boolean $collation The collation, or FALSE if no collation. |
||
55 | */ |
||
56 | public function __construct($charset = 'utf8', $collation = false) |
||
61 | |||
62 | /** |
||
63 | * @param \Doctrine\DBAL\Event\ConnectionEventArgs $args |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | public function postConnect(ConnectionEventArgs $args) |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | public function getSubscribedEvents() |
||
80 | } |
||
81 |
Instead of embedding dynamic parameters in SQL, Doctrine also allows you to pass them separately and insert a placeholder instead: