1 |
<?php |
1 |
<?php |
2 |
|
2 |
|
3 |
/** |
3 |
/** |
4 |
* IO class. |
4 |
* IO class. |
5 |
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License |
5 |
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License |
6 |
* @copyright (c)2003, 2004 Tamlyn Rhodes |
6 |
* @copyright (c)2003, 2004 Tamlyn Rhodes |
7 |
* @version $Id: io_mysql.class.php,v 1.7 2005/11/30 23:02:18 tamlyn Exp $ |
7 |
* @version $Id: io_mysql.class.php,v 1.7 2005/11/30 23:02:18 tamlyn Exp $ |
8 |
*/ |
8 |
*/ |
9 |
|
9 |
|
10 |
//include the base IO class and generic SQL class |
10 |
//include the base IO class and generic SQL class |
11 |
require_once dirname(__FILE__)."/iosql.class.php"; |
11 |
require_once dirname(__FILE__)."/iosql.class.php"; |
12 |
|
12 |
|
13 |
/** |
13 |
/** |
14 |
* Class used to read and write data to and from a MySQL database. |
14 |
* Class used to read and write data to and from a MySQL database. |
15 |
* @package singapore |
15 |
* @package singapore |
16 |
* @author Tamlyn Rhodes <tam at zenology dot co dot uk> |
16 |
* @author Tamlyn Rhodes <tam at zenology dot co dot uk> |
17 |
* @copyright (c)2004 Tamlyn Rhodes |
17 |
* @copyright (c)2004 Tamlyn Rhodes |
18 |
*/ |
18 |
*/ |
19 |
class sgIO_mysql extends sgIOsql |
19 |
class sgIO_mysql extends sgIOsql |
20 |
{ |
20 |
{ |
21 |
/** |
21 |
/** |
22 |
* @param sgConfig pointer to a {@link sgConfig} object representing |
22 |
* @param sgConfig pointer to a {@link sgConfig} object representing |
23 |
* the current script configuration |
23 |
* the current script configuration |
24 |
*/ |
24 |
*/ |
25 |
function sgIO_mysql() |
25 |
function sgIO_mysql() |
26 |
{ |
26 |
{ |
27 |
$this->config =& sgConfig::getInstance(); |
27 |
$this->config =& sgConfig::getInstance(); |
28 |
mysql_connect($this->config->sql_host, $this->config->sql_user, $this->config->sql_pass); |
28 |
mysql_connect($this->config->sql_host, $this->config->sql_user, $this->config->sql_pass); |
29 |
mysql_select_db($this->config->sql_database); |
29 |
mysql_select_db($this->config->sql_database); |
30 |
} |
30 |
} |
31 |
|
31 |
|
32 |
/** |
32 |
/** |
33 |
* Name of IO backend. |
33 |
* Name of IO backend. |
34 |
*/ |
34 |
*/ |
35 |
function getName() |
35 |
function getName() |
36 |
{ |
36 |
{ |
37 |
return "MySQL"; |
37 |
return "MySQL"; |
38 |
} |
38 |
} |
39 |
|
39 |
|
40 |
/** |
40 |
/** |
41 |
* Version of IO backend. |
41 |
* Version of IO backend. |
42 |
*/ |
42 |
*/ |
43 |
function getVersion() |
43 |
function getVersion() |
44 |
{ |
44 |
{ |
45 |
return "$Revision: 1.7 $"; |
45 |
return "$Revision: 1.7 $"; |
46 |
} |
46 |
} |
47 |
|
47 |
|
48 |
/** |
48 |
/** |
49 |
* Author of IO backend. |
49 |
* Author of IO backend. |
50 |
*/ |
50 |
*/ |
51 |
function getAuthor() |
51 |
function getAuthor() |
52 |
{ |
52 |
{ |
53 |
return "Tamlyn Rhodes"; |
53 |
return "Tamlyn Rhodes"; |
54 |
} |
54 |
} |
55 |
|
55 |
|
56 |
/** |
56 |
/** |
57 |
* Brief description of IO backend and it's requirements. |
57 |
* Brief description of IO backend and it's requirements. |
58 |
*/ |
58 |
*/ |
59 |
function getDescription() |
59 |
function getDescription() |
60 |
{ |
60 |
{ |
61 |
return "Uses a MySQL database. Requires a MySQL database server and the MySQL PHP extension."; |
61 |
return "Uses a MySQL database. Requires a MySQL database server and the MySQL PHP extension."; |
62 |
} |
62 |
} |
63 |
|
63 |
|
64 |
function query($query) |
64 |
function query($query) |
65 |
{ |
65 |
{ |
66 |
return mysql_query($query); |
66 |
return mysql_query($query); |
67 |
} |
67 |
} |
68 |
|
68 |
|
69 |
function escape_string($query) |
69 |
function escape_string($query) |
70 |
{ |
70 |
{ |
71 |
return mysql_escape_string($query); |
71 |
return mysql_escape_string($query); |
72 |
} |
72 |
} |
73 |
|
73 |
|
74 |
function fetch_array($res) |
74 |
function fetch_array($res) |
75 |
{ |
75 |
{ |
76 |
return mysql_fetch_array($res); |
76 |
return mysql_fetch_array($res); |
77 |
} |
77 |
} |
78 |
|
78 |
|
79 |
function num_rows($res) |
79 |
function num_rows($res) |
80 |
{ |
80 |
{ |
81 |
return mysql_num_rows($res); |
81 |
return mysql_num_rows($res); |
82 |
} |
82 |
} |
83 |
|
83 |
|
84 |
function error() |
84 |
function error() |
85 |
{ |
85 |
{ |
86 |
return mysql_error(); |
86 |
return mysql_error(); |
87 |
} |
87 |
} |
88 |
|
88 |
|
89 |
} |
89 |
} |
90 |
|
90 |
|
91 |
?> |
91 |
?> |