Files
adminer/plugins/dump-php.php

56 lines
1.3 KiB
PHP
Raw Normal View History

2014-09-18 12:08:10 +02:00
<?php
/** Dump to PHP format
* @author Martin Zeman (Zemistr), http://www.zemistr.eu/
2018-01-14 11:03:54 +01:00
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
2014-09-18 12:08:10 +02:00
*/
2025-04-07 16:32:57 +02:00
class AdminerDumpPhp extends Adminer\Plugin {
2025-03-11 07:21:13 +01:00
protected $output = array();
2014-09-18 12:08:10 +02:00
function dumpFormat() {
return array('php' => 'PHP');
}
function dumpHeaders() {
if ($_POST['format'] == 'php') {
header('Content-Type: text/plain; charset=utf-8');
return 'php';
}
}
function dumpTable($table, $style, $is_view = 0) {
2014-09-18 12:08:10 +02:00
if ($_POST['format'] == 'php') {
$this->output[$table] = array();
2014-09-18 12:08:10 +02:00
return true;
}
}
function dumpData($table, $style, $query) {
if ($_POST['format'] == 'php') {
$result = Adminer\connection()->query($query, 1);
2014-09-18 12:08:10 +02:00
if ($result) {
while ($row = $result->fetch_assoc()) {
$this->output[$table][] = $row;
}
}
return true;
}
}
2025-03-11 08:59:38 +01:00
function dumpFooter() {
if ($_POST['format'] == 'php') {
echo "<?php\n";
var_export($this->output);
echo ";\n";
}
2014-09-18 12:08:10 +02:00
}
protected $translations = array(
'cs' => array('' => 'Export do formátu PHP'),
'de' => array('' => 'Export im PHP-Format'),
'pl' => array('' => 'Zrzucaj do formatu PHP'),
'ro' => array('' => 'Dump în format PHP'),
);
2014-09-18 12:08:10 +02:00
}