Packages

  • Nette
    • Application
      • Application\Diagnostics
      • Application\Responses
      • Application\Routers
      • Application\UI
    • Caching
      • Caching\Storages
    • ComponentModel
    • Config
    • Database
      • Database\Diagnostics
      • Database\Drivers
      • Database\Reflection
      • Database\Table
    • DI
    • Diagnostics
    • Forms
      • Forms\Controls
      • Forms\Rendering
    • Http
    • Iterators
    • Latte
      • Latte\Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
    • Templating
    • Utils
  • NetteModule
  • None
  • PHP

Classes

  • NMsSqlDriver
  • NMySqlDriver
  • NOciDriver
  • NOdbcDriver
  • NPgSqlDriver
  • NSqlite2Driver
  • NSqliteDriver
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (http://nette.org)
 5:  *
 6:  * Copyright (c) 2004, 2011 David Grudl (http://davidgrudl.com)
 7:  *
 8:  * For the full copyright and license information, please view
 9:  * the file license.txt that was distributed with this source code.
10:  * @package Nette\Database\Drivers
11:  */
12: 
13: 
14: 
15: /**
16:  * Supplemental SQLite3 database driver.
17:  *
18:  * @author     David Grudl
19:  * @package Nette\Database\Drivers
20:  */
21: class NSqliteDriver extends NObject implements ISupplementalDriver
22: {
23:     /** @var array */
24:     public $supports = array('meta' => FALSE);
25: 
26:     /** @var NConnection */
27:     private $connection;
28: 
29:     /** @var string  Datetime format */
30:     private $fmtDateTime;
31: 
32: 
33: 
34:     public function __construct(NConnection $connection, array $options)
35:     {
36:         $this->connection = $connection;
37:         $this->fmtDateTime = isset($options['formatDateTime']) ? $options['formatDateTime'] : 'U';
38:     }
39: 
40: 
41: 
42:     /********************* SQL ****************d*g**/
43: 
44: 
45: 
46:     /**
47:      * Delimites identifier for use in a SQL statement.
48:      */
49:     public function delimite($name)
50:     {
51:         return '[' . strtr($name, '[]', '  ') . ']';
52:     }
53: 
54: 
55: 
56:     /**
57:      * Formats date-time for use in a SQL statement.
58:      */
59:     public function formatDateTime(DateTime $value)
60:     {
61:         return $value->format($this->fmtDateTime);
62:     }
63: 
64: 
65: 
66:     /**
67:      * Encodes string for use in a LIKE statement.
68:      */
69:     public function formatLike($value, $pos)
70:     {
71:         $value = addcslashes(substr($this->connection->quote($value), 1, -1), '%_\\');
72:         return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'") . " ESCAPE '\\'";
73:     }
74: 
75: 
76: 
77:     /**
78:      * Injects LIMIT/OFFSET to the SQL query.
79:      */
80:     public function applyLimit(&$sql, $limit, $offset)
81:     {
82:         if ($limit >= 0 || $offset > 0) {
83:             $sql .= ' LIMIT ' . $limit . ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
84:         }
85:     }
86: 
87: 
88: 
89:     /**
90:      * Normalizes result row.
91:      */
92:     public function normalizeRow($row, $statement)
93:     {
94:         return $row;
95:     }
96: 
97: }
98: 
Nette Framework 2.0beta1 (for PHP 5.2) API API documentation generated by ApiGen 2.3.0