- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
public function store($variable){
$insert = "INSERT INTO `".$variable['table']."`(";
foreach ($variable as $key => $value) {
if(trim($key) != 'table'){
$insert = $insert.''.$key.',';
}
}
$insert = substr($insert,0,-1);
$insert = $insert.") VALUES(";
foreach ($variable as $key => $value) {
if(trim($key) != 'table'){
if(trim(gettype($value)) == 'string'){
$insert = $insert.'\''.$value.'\',';
}else{
$insert = $insert.''.$value.',';
}
}
}
$insert = substr($insert,0,-1);
$insert = $insert.')';
foreach ($variable as $key => $value) {
if(trim($key) != 'table'){
if(trim(gettype($value)) == 'string'&&strlen($value) < 512){
$variable[$key] = $key.' TEXT(512),
';
}elseif(trim(gettype($value)) == 'string'&&strlen($value) > 512&&strlen($value) <= 1024){
$variable[$key] = $key.' TEXT(1024),
';
}elseif(trim(gettype($value)) == 'string'&&strlen($value) > 1024&&strlen($value) <= 2048){
$variable[$key] = $key.' TEXT(2048),
';
}elseif(trim(gettype($value)) == 'string'&&strlen($value) > 2048&&strlen($value) <= 4096){
$variable[$key] = $key.' TEXT(4096),
';
}elseif(trim(gettype($value)) == 'string'&&strlen($value) > 4096){
$variable[$key] = $key.' TEXT(65535),
';
}
if(gettype($value) == 'integer'){
$variable[$key] = $key.' INT(128),
';
}
if(gettype($value) == 'double'||gettype($value) == 'float'){
$variable[$key] = $key.' FLOAT(53),
';
}
}
};
$table = "
CREATE TABLE ".$variable['table']."(
id INT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
";
foreach ($variable as $key => $value) {
if(trim($key) != 'table'){
$table = $table.''.$value;
}
};
$table = substr($table,0,-3);
$table = $table.'
)';
}
Комментарии (0) RSS
Добавить комментарий