|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\Cache\Adapter; |
| 13 | + |
| 14 | +use Symfony\Component\Cache\Traits\PdoTrait; |
| 15 | + |
| 16 | +class PdoAdapter extends AbstractAdapter |
| 17 | +{ |
| 18 | + use PdoTrait; |
| 19 | + |
| 20 | + protected $maxIdLength = 255; |
| 21 | + |
| 22 | + /** |
| 23 | + * Constructor. |
| 24 | + * |
| 25 | + * You can either pass an existing database connection as PDO instance or |
| 26 | + * a Doctrine DBAL Connection or a DSN string that will be used to |
| 27 | + * lazy-connect to the database when the cache is actually used. |
| 28 | + * |
| 29 | + * List of available options: |
| 30 | + * * db_table: The name of the table [default: cache_items] |
| 31 | + * * db_id_col: The column where to store the cache id [default: item_id] |
| 32 | + * * db_data_col: The column where to store the cache data [default: item_data] |
| 33 | + * * db_lifetime_col: The column where to store the lifetime [default: item_lifetime] |
| 34 | + * * db_time_col: The column where to store the timestamp [default: item_time] |
| 35 | + * * db_username: The username when lazy-connect [default: ''] |
| 36 | + * * db_password: The password when lazy-connect [default: ''] |
| 37 | + * * db_connection_options: An array of driver-specific connection options [default: array()] |
| 38 | + * |
| 39 | + * @param \PDO|Connection|string $connOrDsn A \PDO or Connection instance or DSN string or null |
| 40 | + * @param string $namespace |
| 41 | + * @param int $defaultLifetime |
| 42 | + * @param array $options An associative array of options |
| 43 | + * |
| 44 | + * @throws InvalidArgumentException When first argument is not PDO nor Connection nor string |
| 45 | + * @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION |
| 46 | + * @throws InvalidArgumentException When namespace contains invalid characters |
| 47 | + */ |
| 48 | + public function __construct($connOrDsn, $namespace = '', $defaultLifetime = 0, array $options = array()) |
| 49 | + { |
| 50 | + $this->init($connOrDsn, $namespace, $defaultLifetime, $options); |
| 51 | + } |
| 52 | +} |
0 commit comments