OpenSencillo
2015.002
|
Public Member Functions | |
newColumn ($name, $type="INT") | |
prepareTable ($name) | |
uniqueKey ($keyName) | |
string $name | |
Create table (use after newColumn function) | |
createTable ($name) | |
openTable ($name) | |
insert ($values) | |
set ($column, $value) | |
update ($if, $sets=null) | |
delete ($if) | |
output ($if="`id`>0", $order="`id` ASC", $limit=1000) | |
Private Attributes | |
$construct | |
$key | |
$table | |
$sql | |
$result | |
$column | |
$setupdate | |
$colout | |
$out | |
$metaout | |
$csum | |
$sizeout |
Definition at line 117 of file core_sql.php.
createTable | ( | $ | name | ) |
Definition at line 164 of file core_sql.php.
{ $this->table = $name; $this->query('CREATE TABLE IF NOT EXISTS `'.$name.'` ( `id` INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`id`)'.$this->construct.');'); $this->construct = null; }
delete | ( | $ | if | ) |
Definition at line 233 of file core_sql.php.
insert | ( | $ | values | ) |
Definition at line 194 of file core_sql.php.
{ $this->query('INSERT INTO '.$this->table.' ('.substr($this->column, 0, -1).') VALUES (null,'.$values.');'); }
newColumn | ( | $ | name, |
$ | type = "INT" |
||
) |
Create new column with type
string | $name | column |
string | $type | column |
Definition at line 137 of file core_sql.php.
{ $this->construct .= ' , `'.$name.'` '.strtoupper($type).''; }
openTable | ( | $ | name | ) |
Open table and read all column names
string | $name |
Definition at line 175 of file core_sql.php.
{ $this->table = $name; $this->sql="SHOW COLUMNS FROM ".$this->DBName.".".$this->table; $this->con=mysql_connect($this->DBHost,$this->DBUser,$this->DBPass); mysql_select_db($this->DBName, $this->con); $this->result=mysql_query($this->sql); $this->column=null; while($row=mysql_fetch_array($this->result)) { $this->column.='`'.$row['Field'].'`,'; } }
output | ( | $ | if = "`id`>0" , |
$ | order = "`id` ASC" , |
||
$ | limit = 1000 |
||
) |
Definition at line 252 of file core_sql.php.
{ $this->sql="SELECT * FROM `".$this->table."` WHERE ".$if." ORDER BY ".$order." LIMIT ".$limit.";"; $this->con=mysql_connect($this->DBHost,$this->DBUser,$this->DBPass); mysql_select_db($this->DBName, $this->con); $this->result=mysql_query($this->sql); $this->colout=explode(",",str_replace("`","",substr($this->column, 0, -1))); $i=0; $j=0; $this->out = array('header'=>$this->colout,'line'=>array(array())); $this->csum = md5($this->con); while($row=mysql_fetch_array($this->result)) { $i=0; $j++; foreach($this->colout as $val) { $this->out['line'][$j][$i++]=$row[$val]; } } return $this->out; }
prepareTable | ( | $ | name | ) |
Light alternative to openTable
string | $name |
Definition at line 146 of file core_sql.php.
{ $this->table = $name; }
set | ( | $ | column, |
$ | value | ||
) |
Use befor update - edit value in the column
string | $column | |
string | $value |
Definition at line 204 of file core_sql.php.
{ if(is_numeric($value)) { $this->setupdate.='`'.$column.'`='.$value.','; } else { $this->setupdate.='`'.$column.'`="'.$value.'",'; } }
uniqueKey | ( | $ | keyName | ) |
Create unique key. Use after prepareTable.
string | $keyName |
Definition at line 155 of file core_sql.php.
{ $this->key .= ' , UNIQUE KEY `'.$this->table.'` (`'.$keyName.'`)'; }
update | ( | $ | if, |
$ | sets = null |
||
) |
Definition at line 222 of file core_sql.php.
{ $this->query('UPDATE '.$this->table.' SET '.substr($this->setupdate, 0, -1).$sets.' WHERE '.$if.';'); }
$colout [private] |
Definition at line 126 of file core_sql.php.
$column [private] |
Definition at line 124 of file core_sql.php.
$construct [private] |
Definition at line 119 of file core_sql.php.
$csum [private] |
Definition at line 129 of file core_sql.php.
$key [private] |
Definition at line 120 of file core_sql.php.
$metaout [private] |
Definition at line 128 of file core_sql.php.
$out [private] |
Definition at line 127 of file core_sql.php.
$result [private] |
Definition at line 123 of file core_sql.php.
$setupdate [private] |
Definition at line 125 of file core_sql.php.
$sizeout [private] |
Definition at line 130 of file core_sql.php.
$sql [private] |
Definition at line 122 of file core_sql.php.
$table [private] |
Definition at line 121 of file core_sql.php.