Overview

Packages

  • Db
    • Adapter
    • Migration

Classes

  • Horde_Db_Adapter_Base
  • Horde_Db_Adapter_Base_Column
  • Horde_Db_Adapter_Base_ColumnDefinition
  • Horde_Db_Adapter_Base_Index
  • Horde_Db_Adapter_Base_Schema
  • Horde_Db_Adapter_Base_Table
  • Horde_Db_Adapter_Base_TableDefinition
  • Horde_Db_Adapter_Mysql
  • Horde_Db_Adapter_Mysql_Column
  • Horde_Db_Adapter_Mysql_Result
  • Horde_Db_Adapter_Mysql_Schema
  • Horde_Db_Adapter_Mysqli
  • Horde_Db_Adapter_Mysqli_Result
  • Horde_Db_Adapter_Pdo_Base
  • Horde_Db_Adapter_Pdo_Mysql
  • Horde_Db_Adapter_Pdo_Pgsql
  • Horde_Db_Adapter_Pdo_Sqlite
  • Horde_Db_Adapter_Postgresql_Column
  • Horde_Db_Adapter_Postgresql_Schema
  • Horde_Db_Adapter_SplitRead
  • Horde_Db_Adapter_Sqlite_Column
  • Horde_Db_Adapter_Sqlite_Schema

Interfaces

  • Horde_Db_Adapter
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Copyright 2007 Maintainable Software, LLC
 4:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
 5:  *
 6:  * @author     Mike Naberezny <mike@maintainable.com>
 7:  * @author     Derek DeVries <derek@maintainable.com>
 8:  * @author     Chuck Hagenbuch <chuck@horde.org>
 9:  * @license    http://www.horde.org/licenses/bsd
10:  * @category   Horde
11:  * @package    Db
12:  * @subpackage Adapter
13:  */
14: 
15: /**
16:  * @author     Mike Naberezny <mike@maintainable.com>
17:  * @author     Derek DeVries <derek@maintainable.com>
18:  * @author     Chuck Hagenbuch <chuck@horde.org>
19:  * @license    http://www.horde.org/licenses/bsd
20:  * @category   Horde
21:  * @package    Db
22:  * @subpackage Adapter
23:  */
24: class Horde_Db_Adapter_Sqlite_Column extends Horde_Db_Adapter_Base_Column
25: {
26:     /**
27:      * @var array
28:      */
29:     protected static $_hasEmptyStringDefault = array('binary', 'string', 'text');
30: 
31: 
32:     public function extractDefault($default)
33:     {
34:         $default = parent::extractDefault($default);
35:         if ($this->isText()) {
36:             $default = $this->_unquote($default);
37:         }
38:         return $default;
39:     }
40: 
41: 
42:     /*##########################################################################
43:     # Type Juggling
44:     ##########################################################################*/
45: 
46:     public function binaryToString($value)
47:     {
48:         return str_replace(array('%00', '%25'), array("\0", '%'), $value);
49:     }
50: 
51:     /**
52:      * @param   mixed  $value
53:      * @return  boolean
54:      */
55:     public function valueToBoolean($value)
56:     {
57:         if ($value == '"t"' || $value == "'t'") {
58:             return true;
59:         } elseif ($value == '""' || $value == "''") {
60:             return null;
61:         } else {
62:             return parent::valueToBoolean($value);
63:         }
64:     }
65: 
66: 
67:     /*##########################################################################
68:     # Protected
69:     ##########################################################################*/
70: 
71:     /**
72:      * Unquote a string value
73:      *
74:      * @return string
75:      */
76:     protected function _unquote($string)
77:     {
78:         $first = substr($string, 0, 1);
79:         if ($first == "'" || $first == '"') {
80:             $string = substr($string, 1);
81:             if (substr($string, -1) == $first) {
82:                 $string = substr($string, 0, -1);
83:             }
84:             $string = str_replace("$first$first", $first, $string);
85:         }
86: 
87:         return $string;
88:     }
89: }
90: 
API documentation generated by ApiGen