|
@@ -23,7 +23,10 @@ class Sql
|
|
|
}
|
|
|
public static function create($config)
|
|
|
{
|
|
|
- $sql = 'CREATE TABLE `' . $config['table'] . '`(';
|
|
|
+ if (isset(Config::get('setting')['database']['create']) && !Config::get('setting')['database']['create']) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $sql = 'DROP TABLE IF EXISTS `' . $config['table'] . '`;CREATE TABLE IF NOT EXISTS `' . $config['table'] . '`(';
|
|
|
$struct = array('id' => array('name' => 'ID', 'type' => 'int(11)'),'cdate' => array('name' => 'cdate', 'type' => 'int(11)'));
|
|
|
$struct = array_merge($struct, $config['struct']);
|
|
|
foreach ($struct as $k => $v) {
|
|
@@ -288,6 +291,9 @@ class Sql
|
|
|
{
|
|
|
$sql = 'INSERT INTO `' . $table . '` SET ';
|
|
|
foreach ($data as $k => $v) {
|
|
|
+ if (!$v && $v !== 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if ($field && empty($field[$k]) && strpos('id,cdate', $k) === false) {
|
|
|
continue;
|
|
|
}
|