This repository was archived by the owner on Mar 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDb.php
More file actions
67 lines (61 loc) · 1.36 KB
/
Db.php
File metadata and controls
67 lines (61 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Database handling
*
* @package Core
* @author Jeremy MOULIN <jeremy.moulin@doonoyz.com>
* @copyright 2008-2009 Doonoyz
* @version Paper
*/
class Gears_Db {
/**
* database instance
*
* @var resource
*/
private $_db;
/**
* Id of the last insert
*
* @var int
*/
private $_id;
/**
* Show debug informations
*
* @var int 0 => nothing, 1 => show insert only , 2 => show select only, 3 => show both
*/
private $_showDebug = 0;
/**
* Parameters for mysql connection
*
* @var Array
*/
private $_params = Array ();
/**
* Static function to connect DB within config and Zend_Db
*
* @param string $setting Settings to connect DB, if null, user config.ini informations, can be "user" to connect in user DB or "location" to connect location service
*
* @return Zend_Db|NULL
*/
public static function getDb($setting = NULL) {
$config = new Zend_Config_Ini ( ROOT_DIR . 'application/config.ini', ENVIRONMENT );
return (Zend_Db::factory ( $config->db->adapter, $config->db->config->toArray () ));
}
/**
* Constructor forbidden, static only instance
*
* @return NULL
*/
private function __construct() {
throw new GearsDbException('Must call Gears_Db::getDb() instead');
return;
}
}
/**
* GearsDbException thrown if class called be constructor
*
*/
class GearsDbException extends Zend_Exception {
}