Beispiel #1
0
<?php

/*--------------------------------------------------------------------*
 | Copyright (c) 2010-2013 Vayer Software Ltd. - All Rights Reserved. |
 *--------------------------------------------------------------------*/
require_once __INC__ . '/mysql.php';
require_once __INC__ . '/export_stuff.php';
date_default_timezone_set("UTC");
$q = MySQLQuery::SimpleQuery($LINK, 'SELECT VERSION()', TRUE);
if ($q === FALSE) {
    return $LINK->error;
}
$file = new TempFile(NULL, 'UTF-8', $ARGS['file_encoding']);
$db = $ARGS['db'];
$disFKeys = $ARGS['tables_data'] && $ARGS['no_foreign_keys'];
$file->write(getExportHeader($disFKeys, $q[0][0], $db));
function delimit(&$s)
{
    if (strrchr($s, ";")) {
        $delim = "\$\$";
        while (strstr($s, $delim)) {
            $delim .= $delim;
        }
        return "DELIMITER {$delim}\n\n{$s}{$delim}\n\nDELIMITER ;\n\n\n";
    }
    return $s . ";\n\n\n";
}
if ($ARGS['with_create_db']) {
    if ($ARGS['with_drop_db']) {
        $file->write("DROP DATABASE IF EXISTS `{$db}`;\n");
    }
Beispiel #2
0
 public function handleResultStarted(&$fields)
 {
     $this->fields = $fields;
     $this->target = $this->args['target'];
     $this->file->write(getExportHeader($this->args['no_foreign_keys']));
     if ($this->args['with_lock']) {
         $this->file->write("LOCK TABLES `{$this->target}` WRITE;\n");
     }
     $this->file->write("ALTER TABLE `{$this->target}` DISABLE KEYS;\n\n");
     $a = array();
     foreach ($fields as $f) {
         $a[] = '`' . $f['fieldAlias'] . '`';
     }
     $this->insert_stmt = "INSERT INTO `{$this->target}` (" . implode(',', $a) . ") VALUES ";
 }