CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • Mysql
  • Postgres
  • Sqlite
  • Sqlserver

Traits

  • PDODriverTrait
  1: <?php
  2: /**
  3:  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4:  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5:  *
  6:  * Licensed under The MIT License
  7:  * For full copyright and license information, please see the LICENSE.txt
  8:  * Redistributions of files must retain the above copyright notice.
  9:  *
 10:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 11:  * @link          https://cakephp.org CakePHP(tm) Project
 12:  * @since         3.0.0
 13:  * @license       https://opensource.org/licenses/mit-license.php MIT License
 14:  */
 15: namespace Cake\Database\Driver;
 16: 
 17: use Cake\Database\Dialect\SqliteDialectTrait;
 18: use Cake\Database\Driver;
 19: use Cake\Database\Query;
 20: use Cake\Database\Statement\PDOStatement;
 21: use Cake\Database\Statement\SqliteStatement;
 22: use PDO;
 23: 
 24: /**
 25:  * Class Sqlite
 26:  */
 27: class Sqlite extends Driver
 28: {
 29:     use SqliteDialectTrait;
 30: 
 31:     /**
 32:      * Base configuration settings for Sqlite driver
 33:      *
 34:      * - `mask` The mask used for created database
 35:      *
 36:      * @var array
 37:      */
 38:     protected $_baseConfig = [
 39:         'persistent' => false,
 40:         'username' => null,
 41:         'password' => null,
 42:         'database' => ':memory:',
 43:         'encoding' => 'utf8',
 44:         'mask' => 0644,
 45:         'flags' => [],
 46:         'init' => [],
 47:     ];
 48: 
 49:     /**
 50:      * Establishes a connection to the database server
 51:      *
 52:      * @return bool true on success
 53:      */
 54:     public function connect()
 55:     {
 56:         if ($this->_connection) {
 57:             return true;
 58:         }
 59:         $config = $this->_config;
 60:         $config['flags'] += [
 61:             PDO::ATTR_PERSISTENT => $config['persistent'],
 62:             PDO::ATTR_EMULATE_PREPARES => false,
 63:             PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
 64:         ];
 65: 
 66:         $databaseExists = file_exists($config['database']);
 67: 
 68:         $dsn = "sqlite:{$config['database']}";
 69:         $this->_connect($dsn, $config);
 70: 
 71:         if (!$databaseExists && $config['database'] != ':memory:') {
 72:             //@codingStandardsIgnoreStart
 73:             @chmod($config['database'], $config['mask']);
 74:             //@codingStandardsIgnoreEnd
 75:         }
 76: 
 77:         if (!empty($config['init'])) {
 78:             foreach ((array)$config['init'] as $command) {
 79:                 $this->getConnection()->exec($command);
 80:             }
 81:         }
 82: 
 83:         return true;
 84:     }
 85: 
 86:     /**
 87:      * Returns whether php is able to use this driver for connecting to database
 88:      *
 89:      * @return bool true if it is valid to use this driver
 90:      */
 91:     public function enabled()
 92:     {
 93:         return in_array('sqlite', PDO::getAvailableDrivers(), true);
 94:     }
 95: 
 96:     /**
 97:      * Prepares a sql statement to be executed
 98:      *
 99:      * @param string|\Cake\Database\Query $query The query to prepare.
100:      * @return \Cake\Database\StatementInterface
101:      */
102:     public function prepare($query)
103:     {
104:         $this->connect();
105:         $isObject = $query instanceof Query;
106:         $statement = $this->_connection->prepare($isObject ? $query->sql() : $query);
107:         $result = new SqliteStatement(new PDOStatement($statement, $this), $this);
108:         if ($isObject && $query->isBufferedResultsEnabled() === false) {
109:             $result->bufferResults(false);
110:         }
111: 
112:         return $result;
113:     }
114: 
115:     /**
116:      * {@inheritDoc}
117:      */
118:     public function supportsDynamicConstraints()
119:     {
120:         return false;
121:     }
122: }
123: 
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs