| | |
| | | * @param string DSN for read/write operations |
| | | * @param string Optional DSN for read only operations |
| | | */ |
| | | function __construct($db_dsnw, $db_dsnr='') |
| | | function __construct($db_dsnw, $db_dsnr='', $pconn=false) |
| | | { |
| | | if ($db_dsnr=='') |
| | | $db_dsnr=$db_dsnw; |
| | | |
| | | $this->db_dsnw = $db_dsnw; |
| | | $this->db_dsnr = $db_dsnr; |
| | | |
| | | $this->db_pconn = $pconn; |
| | | |
| | | $dsn_array = MDB2::parseDSN($db_dsnw); |
| | | $this->db_provider = $dsn_array['phptype']; |
| | | } |
| | |
| | | function dsn_connect($dsn) |
| | | { |
| | | // Use persistent connections if available |
| | | $dbh = MDB2::connect($dsn, array('persistent' => TRUE, 'portability' => MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL)); |
| | | $dbh = MDB2::connect($dsn, array('persistent' => $this->db_pconn, 'portability' => MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL)); |
| | | |
| | | if (PEAR::isError($dbh)) |
| | | { |
| | |
| | | if (!$this->db_handle) |
| | | return FALSE; |
| | | |
| | | return $result; |
| | | return $this->_get_result($result); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Return SQL function for current time and date |
| | | * |
| | | * @return string SQL function to use in query |
| | | * @access public |
| | | */ |
| | | function now() |
| | | { |
| | | switch($this->db_provider) |
| | | { |
| | | case 'mssql': |
| | | return "getdate()"; |
| | | |
| | | default: |
| | | return "now()"; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Return SQL statement to convert a field value into a unix timestamp |
| | | * |
| | | * @param string Field name |
| | |
| | | return "EXTRACT (EPOCH FROM $field)"; |
| | | break; |
| | | |
| | | case 'mssql': |
| | | return "datediff(s, '1970-01-01 00:00:00', $field)"; |
| | | |
| | | default: |
| | | return "UNIX_TIMESTAMP($field)"; |
| | | } |