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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102 | <?
/***************************************************
QUERY class
Version 1.1.0
New version is PHP5 competable
Owner Dinamik Elektronik ve Bilisim Ltd.
Written by Suleyman Cabir CIPLAK
*****************************************************/
class Query {
public $str;
private $host;
private $user;
private $pass;
private $db;
private $dataByName = array();
private $isRead = false;
private $query;
public $rows = 0;
public $cols = 0;
public $version = "1.0.0";
public function Query($strSQL) {
$this->str = $strSQL;
}
public function connect($host, $user, $pass, $db){
if(QUERY_IS_CONNECTED) {
if(@mysql_connect($host, $user, $pass) && mysql_select_db($db)) {
define("QUERY_IS_CONNECTED", true);
}
}
return true;
}
public function run() {
$this->query = mysql_query($this->str);
}
public function set($strSQL) {
$this->str = $strSQL;
}
private function read() {
if(!$this->isRead) {
$i = 1;
$this->run();
while ($rows = @mysql_fetch_array($this->query)) {
$this->dataByName[$i] = $rows;
$i++;
}
$this->isRead = true;
}
}
public function get($row, $col) {
$this->read();
return $this->dataByName[$row][$col];
}
public function getRow($row) {
$this->read();
return $this->dataByName[$row];
}
public function rows() {
$this->rows = @mysql_num_rows($this->query);
return $this->rows;
}
public function allRows() {
$strSQL = explode('LIMIT', $this->str);
$query = mysql_query($strSQL[0]);
return mysql_num_rows($query);
}
public function cols() {
$this->cols = mysql_num_fields($this->query);
return $this->cols;
}
public function orderBy($param) {
return mysql_insert_id();
}
public function getInsertId() {
return mysql_insert_id();
}
}
?>
|