mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
change datetime not null default 0000
This commit is contained in:
@@ -267,7 +267,7 @@ class NexusDB
|
||||
return DB::transaction($callback, $attempts);
|
||||
}
|
||||
|
||||
public static function getMysqlColumnInfo($table, $column)
|
||||
public static function getMysqlColumnInfo($table, $column = null)
|
||||
{
|
||||
static $driver;
|
||||
$config = nexus_config('nexus.mysql');
|
||||
@@ -276,11 +276,22 @@ class NexusDB
|
||||
$driver->connect($config['host'], $config['username'], $config['password'], 'information_schema', $config['port']);
|
||||
}
|
||||
$sql = sprintf(
|
||||
"select * from COLUMNS where TABLE_SCHEMA = '%s' and TABLE_NAME = '%s' and COLUMN_NAME = '%s'",
|
||||
$config['database'], $table, $column
|
||||
"select * from COLUMNS where TABLE_SCHEMA = '%s' and TABLE_NAME = '%s'",
|
||||
$config['database'], $table
|
||||
);
|
||||
if ($column !== null) {
|
||||
$sql .= " and COLUMN_NAME = '$column'";
|
||||
}
|
||||
$res = $driver->query($sql);
|
||||
return $driver->fetchAssoc($res);
|
||||
if ($column !== null) {
|
||||
return $driver->fetchAssoc($res);
|
||||
}
|
||||
$results = [];
|
||||
while ($row = $driver->fetchAssoc($res)) {
|
||||
$results[$row['COLUMN_NAME']] = $row;
|
||||
}
|
||||
return $results;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user