Changeset 8249
- Timestamp:
- 04/03/08 23:18:59 (1 year ago)
- Files:
-
- branches/1.1/lib/database/sfPDODatabase.class.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/database/sfPDODatabase.class.php
r7792 r8249 5 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 6 * (c) 2004-2006 Sean Kerr <sean@code-box.org> 7 * 7 * 8 8 * For the full copyright and license information, please view the LICENSE 9 9 * file that was distributed with this source code. … … 18 18 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 19 19 * @author Sean Kerr <sean@code-box.org> 20 * @author Dustin Whittle <dustin.whittle@symfony-project.com> 20 21 * @version SVN: $Id$ 21 22 */ … … 36 37 { 37 38 case 'dsn': 39 38 40 $dsn = $this->getParameter('dsn'); 39 41 … … 49 51 try 50 52 { 51 $pdo_username = $this->getParameter('username'); 52 $pdo_password = $this->getParameter('password'); 53 $pdo_class = $this->getParameter('class', 'PDO'); 53 $pdo_class = $this->getParameter('class', 'PDO'); 54 $username = $this->getParameter('username'); 55 $password = $this->getParameter('password'); 56 $persistent = $this->getParameter('persistent'); 54 57 55 $this->connection = new $pdo_class($dsn, $pdo_username, $pdo_password); 58 $options = ($persistent) ? array(PDO::ATTR_PERSISTENT => true) : array(PDO::ATTR_PERSISTENT => false); 59 60 $this->connection = new $pdo_class($dsn, $username, $password, $options); 61 56 62 } 57 63 catch (PDOException $e) … … 61 67 62 68 // lets generate exceptions instead of silent failures 63 if (defined('PDO::ATTR_ERRMODE'))69 if(sfConfig::get('sf_debug')) 64 70 { 65 71 $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); … … 67 73 else 68 74 { 69 $this->connection->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION); 75 $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); 76 } 77 78 // compatability 79 $compatability = $this->getParameter('compat'); 80 if($compatability) 81 { 82 $this->connection->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL); 83 } 84 85 // nulls 86 $nulls = $this->getParameter('nulls'); 87 if($nulls) 88 { 89 $this->connection->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING); 90 } 91 92 // auto commit 93 $autocommit = $this->getParameter('autocommit'); 94 if($autocommit) 95 { 96 $this->connection->setAttribute(PDO::ATTR_AUTOCOMMIT, true); 70 97 } 71 98 72 99 $this->resource = $this->connection; 100 73 101 } 74 102 75 103 /** 76 * Execute sthe shutdown procedure.104 * Execute the shutdown procedure. 77 105 * 78 106 * @return void 107 */ 108 public function shutdown () 109 { 110 if ($this->connection !== null) 111 { 112 @$this->connection = null; 113 } 114 } 115 116 /** 117 * Magic method for calling PDO directly via sfPDODatabase 79 118 * 80 * @throws <b>sfDatabaseException</b> If an error occurs while shutting down this database 119 * @param string $method 120 * @param array $arguments 121 * @return mixed 81 122 */ 82 public function shutdown()123 public function __call($method, $arguments) 83 124 { 84 $this->connection = null;125 return $this->getConnection()->$method($arguments); 85 126 } 86 127 }

