50 if(($this->DBHost!=
'')&&($this->DBUser!=
'')&&($this->DBPass!=
'')&&($this->DBName!=
''))
52 $this->checksum=md5($this->DBHost.$this->DBUser.$this->DBPass.$this->DBName);
54 $this->con = mysql_connect($this->DBHost, $this->DBUser, $this->DBPass);
57 die(
"<b>core_sql: MySQL connection failed!</b> ".mysql_error());
59 mysql_select_db($this->DBName, $this->con);
85 mysql_close($this->con);
92 final public function test()
94 if($this->checksum==md5($this->DBHost.$this->DBUser.$this->DBPass.$this->DBName))
138 $this->construct .=
' , `'.$name.
'` '.strtoupper($type).
'';
147 $this->table = $name;
148 $this->
query(
'CREATE TABLE IF NOT EXISTS `'.$name.
'` ( `id` INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`id`)'.$this->construct.
');');
157 $this->table = $name;
158 $this->sql=
"SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA`='".$this->DBName.
"' AND `TABLE_NAME`='".$this->table.
"';";
159 $this->con=mysql_connect($this->DBHost,$this->DBUser,$this->DBPass);
160 mysql_select_db($this->DBName, $this->con);
161 $this->result=mysql_query($this->sql);
162 while($row=mysql_fetch_array($this->result))
164 $this->column.=
'`'.$row[
'COLUMN_NAME'].
'`,';
175 $this->
query(
'INSERT INTO '.$this->table.
' ('.substr($this->column, 0, -1).
') VALUES (null,'.$values.
');');
183 public function set($column,$value)
185 if(is_numeric($value))
187 $this->setupdate.=
'`'.$column.
'`='.$value.
',';
191 $this->setupdate.=
'`'.$column.
'`="'.$value.
'",';
203 $this->
query(
'UPDATE '.$this->table.
' SET '.substr($this->setupdate, 0, -1).$sets.
' WHERE '.$if.
';');
212 public function delete($if)
216 $this->
query(
'DELETE FROM `'.$this->table.
'` WHERE `id`>0;');
220 $this->
query(
'DELETE FROM `'.$this->table.
'` WHERE '.$if.
';');
231 public function output($if=
"`id`>0",$order=
"`id` ASC",$limit=1000)
233 $this->sql=
"SELECT * FROM `".$this->table.
"` WHERE ".$if.
" ORDER BY ".$order.
" LIMIT ".$limit.
";";
234 $this->con=mysql_connect($this->DBHost,$this->DBUser,$this->DBPass);
235 mysql_select_db($this->DBName, $this->con);
236 $this->result=mysql_query($this->sql);
237 $this->colout=explode(
",",str_replace(
"`",
"",substr($this->column, 0, -1)));
240 $this->out = array(
'header'=>$this->colout,
'line'=>array(array()));
241 $this->csum = md5($this->con);
242 while($row=mysql_fetch_array($this->result))
246 while(
sizeof($this->colout)>
$i)
248 $this->out[
'line'][$j][
$i]=$row[$this->colout[
$i++]];
newColumn($name, $type="INT")
__construct($DBHost, $DBName, $DBUser, $DBPass)
output($if="`id`>0", $order="`id` ASC", $limit=1000)