Posted by HHH on 06/13/2009
0 Commentssave as: dbcon.php
Read more...
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.
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.
<?php
class db {
var $query_count = 0;
var $connection_id = "";
var $query_id = "";
var $record_row = array();
var $cf = array();
var $obj = array (
'sql_host' => '',
'sql_user' => '',
'sql_pass' => '',
'sql_database' => ''
);
function connect()
{
$this->connection_id = @mysql_connect($this->obj['sql_host'], $this->obj['sql_user'], $this->obj['sql_pass']);
@mysql_select_db($this->obj['sql_database'],$this->connection_id) or $this->err(mysql_error());
}
function query($query)
{
$this->query_count++;
$this->query_id = mysql_query($query, $this->connection_id) or $this->err(mysql_error());
return $this->query_id;
}
function fetch_array($query)
{
$this->record_row = mysql_fetch_array($query, MYSQL_ASSOC);
return $this->record_row;
}
function get_num_rows($query) {
return mysql_num_rows($query);
}
function get_query_cnt()
{
return $this->query_count;
}
function close()
{
if ( $this->connection_id )
{
return @mysql_close( $this->connection_id );
}
}
function err($error)
{
echo "Database Error: $error";
}
}
?>
Read more...