PdoAdapter.php 2.2 KB

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