コード例 #1
0
function createMigration($mysqli, $indent = 2)
{
    $output = array();
    foreach (getTables($mysqli) as $table) {
        $output[] = getTableMigration($table, $mysqli, $indent);
    }
    return implode(PHP_EOL, $output) . PHP_EOL;
}
コード例 #2
0
function loadTables()
{
    $filename = dirname(__FILE__) . "/../database_desc.txt";
    if (!file_exists($filename)) {
        echo "<!DOCTYPE html><body>\n\t\t\t<div style='display:inline-block; color:red; font-weight:bold;'>Error:</div>\n\t\t\tfile\n\t\t\t<div style='display:inline-block; font-family:monospace;'>{$filename}</div>\n\t\t\tdescribing the tables does not exist!<br />\n\t\t\tPlease retrieve this file and try again.\n\t\t\t</body>";
        return;
    }
    $a_file_tables = unserialize(file_get_contents($filename));
    $a_file_tables = $a_file_tables["Tables"];
    $a_tables = getTables();
    updateTables($a_tables, $a_file_tables);
    echo "success";
}
コード例 #3
0
ファイル: functions.php プロジェクト: nitr0man/fiberms
function dropTmpTables($in_transaction = false)
{
    $tables = getTables();
    $query = $in_transaction ? '' : 'BEGIN; LOCK "MapSettings";';
    $tbl_del = "";
    for ($i = 0; $i < count($tables); $i++) {
        $table = $tables[$i];
        $tmpT = tmpTable($table, TRUE);
        if (strlen($tbl_del) > 0) {
            $tbl_del .= ', ';
        }
        $tbl_del .= '"' . $tmpT . '"';
    }
    //$query .= ' TRUNCATE '.$tbl_del.';';
    $query .= ' DROP TABLE IF EXISTS ' . $tbl_del . ' CASCADE;';
    if (!$in_transaction) {
        $query .= ' COMMIT;';
    }
    //print($query);
    return PQuery($query);
}
コード例 #4
0
ファイル: map.php プロジェクト: nitr0man/fiberms
function saveTmpData()
{
    $query = 'BEGIN; LOCK "MapSettings";';
    $tables = getTables();
    $tbl_del = "";
    $ins = "";
    for ($i = 0; $i < count($tables); $i++) {
        $table = $tables[$i];
        $tmpT = tmpTable($table, TRUE);
        if (strlen($tbl_del) > 0) {
            $tbl_del .= ', ';
        }
        $tbl_del .= '"' . $table . '"';
        $ins .= ' INSERT INTO "' . $table . '" SELECT * FROM "' . $tmpT . '";';
    }
    $query .= ' TRUNCATE ' . $tbl_del . ' CASCADE;' . $ins;
    $query .= ' COMMIT;';
    $res = PQuery($query);
    if (!isset($res['error'])) {
        $res = setMapLastEdit();
    }
    if (!isset($res['error'])) {
        $res = CheckData();
    }
    return $res;
}
コード例 #5
0
ファイル: setup.php プロジェクト: hoksi/Textcube
function checkTables($version, $prefix)
{
    if (!($tables = getTables($version, $prefix))) {
        return false;
    }
    foreach ($tables as $table) {
        if ($result = POD::query("DESCRIBE {$table}")) {
            POD::free($result);
        } else {
            return false;
        }
    }
    return true;
}
コード例 #6
0
ファイル: cron_legacy.php プロジェクト: HobbyNToys/SysCP
/**
 * STARTING REDUNDANT CODE, WHICH IS SOME KINDA HEADER FOR EVERY CRON SCRIPT.
 * When using this "header" you have to change $lockFilename for your needs.
 * Don't forget to also copy the footer which closes database connections
 * and the lockfile! (Note: This "header" also establishes a mysql-root-
 * connection, if you don't need it, see for the header in cron_tasks.php)
 */
$needrootdb = true;
include dirname(__FILE__) . '/../lib/cron_init.php';
/**
 * END REDUNDANT CODE (CRONSCRIPT "HEADER")
 */
/**
 * Check if table exists, otherwise create it
 */
$tables = getTables($db);
if (!isset($tables[TABLE_PANEL_CRONSCRIPT]) || !is_array($tables[TABLE_PANEL_CRONSCRIPT])) {
    $db->query('CREATE TABLE `' . TABLE_PANEL_CRONSCRIPT . '` (  `id` int(11) unsigned NOT NULL auto_increment,  `file` varchar(255) NOT NULL default \'\',  PRIMARY KEY  (`id`) ) TYPE=MyISAM ; ');
}
/**
 * Backend Wrapper
 */
$query = 'SELECT * FROM `' . TABLE_PANEL_CRONSCRIPT . '` ';
$cronFileIncludeResult = $db->query($query);
while ($cronFileIncludeRow = $db->fetch_array($cronFileIncludeResult)) {
    $cronFileIncludeFullPath = makeSecurePath($pathtophpfiles . '/scripts/' . $cronFileIncludeRow['file']);
    if (fileowner($cronFileIncludeFullPath) == fileowner($pathtophpfiles . '/scripts/' . $filename) && filegroup($cronFileIncludeFullPath) == filegroup($pathtophpfiles . '/scripts/' . $filename)) {
        fwrite($debugHandler, 'Processing ...' . $cronFileIncludeFullPath . "\n");
        include_once $cronFileIncludeFullPath;
        fwrite($debugHandler, 'Processing done!' . "\n");
    } else {
コード例 #7
0
ファイル: install.php プロジェクト: edubort/openclinic-1
        // @todo use fieldset
        echo HTML::start('form', array('method' => 'post', 'action' => $_SERVER['PHP_SELF'] . '?confirm=yes'));
        echo HTML::para(Form::button("continue", _("Continue")) . Form::generateToken());
        echo HTML::end('form');
        echo HTML::para(HTML::link(_("Cancel"), './index.php'));
        include_once "../layout/footer.php";
        exit;
    }
}
$setQ->close();
unset($setQ);
unset($set);
/**
 * Creating each table listed in the $tables array
 */
$tables = getTables();
foreach ($tables as $tableName) {
    $result = parseSqlFile("./sql/" . $tableName . ".sql", $tableName, true);
    if ($result) {
        $text = sprintf(_("Table %s dropped."), $tableName) . PHP_EOL;
        $text .= sprintf(_("Table %s created."), $tableName) . PHP_EOL;
        $text .= str_repeat(".", 50);
        echo HTML::para(nl2br($text));
    } else {
        echo Msg::error(_("Last instruction failed"));
        include_once "../layout/footer.php";
        exit;
    }
}
echo Msg::info(_("OpenClinic tables have been created successfully!"));
echo HTML::section(1, HTML::link(_("Start using OpenClinic"), '../home/index.php'));
コード例 #8
0
ファイル: DataSystem.php プロジェクト: censam/lara-scaffold
 /**
  * Analyse data and get ondata specification
  *
  * @param Array $data
  * @todo  optimisation
  */
 private function Tables($data)
 {
     $tmp = getTables($data);
     $this->onData = $tmp[0];
     $this->foreignKeys = $tmp[1];
 }
コード例 #9
0
ファイル: objednavky.php プロジェクト: zcsevcik/edu
function render_body()
{
    if ($_GET['action'] == 'pridej-objednavku') {
        echo '
		<form action="objednavky.php?action=pridej-objednavku2" method="POST">
			<select name="stul">
				' . getTables() . '
			</select> Stul<br />
			Jidlo<br />
			<select name="jidlo">
				' . getFood() . '
			</select>
			<input type="text" name="mnozstvi" size="3" value="1">x pocet kusu<br />
			<input type="submit" value="Pridej jidlo">
		</form>';
    } elseif ($_GET['action'] == 'pridej-objednavku2') {
        if (is_numeric($_POST['mnozstvi'])) {
            $jidlo = MyDB::getInstance()->getResults('SELECT * FROM jidelni_listek WHERE id = ' . MyDB::escape($_POST['jidlo']));
            $cena = $jidlo[0]['cena'];
            for ($i = 1; $i <= $_POST['mnozstvi']; $i++) {
                MyDB::getInstance()->exec('INSERT INTO objednavka ("id_jidla","id_stolu","datum","cena") VALUES (' . MyDB::escape($_POST['jidlo']) . ', ' . MyDB::escape($_POST['stul']) . ', DATETIME("now"), "' . $cena . '")');
                //echo 'INSERT INTO objednavka ("id_jidla","id_stolu","datum","cena") VALUES ('.MyDB::escape($_POST['jidlo']).', '.MyDB::escape($_POST['stul']).', DATETIME("now"), "'.$cena.'")';
            }
            echo '<meta http-equiv="refresh" content="0;URL=\'objednavky.php\'">';
        } else {
            echo 'Zadejte platné množství!';
        }
    } elseif ($_GET['action'] == 'zaplatit') {
        MyDB::getInstance()->exec('UPDATE objednavka SET zaplaceno = 1 WHERE id = ' . MyDB::escape($_GET['id']));
        echo '<meta http-equiv="refresh" content="0;URL=\'objednavky.php\'">';
    } elseif ($_GET['action'] == 'zrusit') {
        MyDB::getInstance()->exec('DELETE FROM objednavka WHERE id = ' . MyDB::escape($_GET['id']));
        echo '<meta http-equiv="refresh" content="0;URL=\'objednavky.php\'">';
    } else {
        return '
	    <h1>Nezaplacené objednávky</h1>
	    <table class="datatable">
	    	<thead>
	    		<tr>
	    			<th>Stůl (salónek)</th>
	    			<th>Jídlo</th>
	    			<th>Čas</th>
	    			<th>Cena</th>
	    			<th>Možnosti</th>
	    		</tr>
	    	</thead>
	    	<tbody>
	    		' . displayOrders('neplacene') . '
	    	</tbody>
	    </table>

	    <br /><br />
		<p><a href="objednavky.php?action=pridej-objednavku"><img src="images/add.png" />Pridej jidlo</a></p>

		<h1>Zaplacené objednávky</h1>
		<table class="datatable">
	    	<thead>
	    		<tr>
	    			<th>Stůl (salónek)</th>
	    			<th>Jídlo</th>
	    			<th>Čas</th>
	    			<th>Cena</th>
	    			<th>Možnosti</th>
	    		</tr>
	    	</thead>
	    	<tbody>
	    		' . displayOrders('placene') . '
	    	</tbody>
	    </table>
	    ';
    }
}
コード例 #10
0
    foreach ($columns as $column) {
        $attributeList[] = $column->getName();
        $typeList[] = $column->getType();
    }
    $_SESSION['objectName'] = $objectName;
    $_SESSION['attributeList'] = serialize($attributeList);
    $_SESSION['typeList'] = serialize($typeList);
    $_SESSION['classList'] = serialize([]);
}
if (!isset($_POST['send']) || $_POST['send'] !== "1") {
    backWithMessage('Please send request from scanner.php');
}
$host = cleanInputData('host');
$username = cleanInputData('username');
$password = cleanInputData('password');
$dbName = cleanInputData('db_name');
$tableName = cleanInputData('table_name');
$objectName = cleanInputData('object_name');
if (empty($host) || empty($username) || empty($password) || empty($dbName) || empty($tableName) || empty($objectName)) {
    backWithMessage('Please fill all required fields');
}
$pdoConnection = new PDO(sprintf("mysql:dbname=%s;host=%s", $dbName, $host), $username, $password);
$columnFactory = new ColumnFactory();
$tables = getTables($pdoConnection);
if (!in_array($tableName, $tables)) {
    backWithMessage(sprintf('Table %s not exists in %s', $tableName, $dbName));
}
$columns = getColumns($pdoConnection, $columnFactory, $tableName);
serializeTableConfig($objectName, $columns);
session_write_close();
header("Location: ../index.php");
コード例 #11
0
ファイル: GenCode.php プロジェクト: ksecor/civicrm
    $file = $argv[1];
} else {
    $file = 'schema/Schema.xml';
}
$sqlCodePath = '../sql/';
$phpCodePath = '../';
$tplCodePath = '../templates/';
echo "Parsing input file {$file}\n";
$dbXML = parseInput($file);
//print_r( $dbXML );
echo "Extracting database information\n";
$database =& getDatabase($dbXML);
// print_r( $database );
$classNames = array();
echo "Extracting table information\n";
$tables =& getTables($dbXML, $database);
resolveForeignKeys($tables, $classNames);
$tables = orderTables($tables);
//echo "\n\n\n\n\n*****************************************************************************\n\n";
//print_r(array_keys($tables));
//exit(1);
echo "Generating tests truncate file\n";
$truncate = '<?xml version="1.0" encoding="UTF-8" ?>
<!--  Truncate all tables that will be used in the tests  -->
<dataset>';
$tbls = array_keys($tables);
foreach ($tbls as $d => $t) {
    $truncate = $truncate . "\n  <{$t} />\n";
}
$truncate = $truncate . "</dataset>\n";
$ft = fopen($sqlCodePath . "../tests/phpunit/CiviTest/truncate.xml", "w");
コード例 #12
0
ファイル: ch_collate.php プロジェクト: dalinhuang/shopexts
<BODY style="font-size:12px;">

<?php 
include "include/mall_config.php";
$CFG['host'] = $dbHost;
$CFG['user'] = $dbUser;
$CFG['password'] = $dbPass;
$CFG['database'] = $dbName;
set_time_limit(0);
error_reporting(E_ALL ^ E_NOTICE);
define('MYSQL_CHARSET', 'latin1');
define('MYSQL_COLLATION', ' 	latin1_swedish_ci');
$REGION = array('mall_binding_tag', 'mall_comment_param', 'mall_comment_score', 'mall_coupons_items', 'mall_discount_coupons', 'mall_extend_tag', 'mall_gifts', 'mall_gifts_cat', 'mall_gift_items', 'mall_goodsgrp_price', 'mall_goods_cache', 'mall_goods_cache_price', 'mall_goods_cache_prop', 'mall_goods_package', 'mall_goods_prop', 'mall_goods_prop_grp', 'mall_goods_prop_grp_value', 'mall_member_coupons', 'mall_member_price', 'mall_pcat_brand', 'mall_pcat_prop', 'mall_pcat_prop_fields', 'mall_pcat_prop_has_goods', 'mall_point_history', 'mall_prop', 'mall_prop_category', 'mall_prop_goods', 'mall_prop_value', 'mall_t_coupons_goods', 'mall_t_coupons_level', 'mall_t_coupons_pcat');
$rs = mysql_connect($CFG['host'], $CFG['user'], $CFG['password']);
mysql_select_db($CFG['database'], $rs);
getTables($rs);
function getTables($rs)
{
    global $REGION;
    $exec_array = array();
    if (!is_array($REGION) || empty($REGION) || !isset($REGION)) {
        $result_t = mysql_query("SHOW TABLES", $rs);
        $REGION = array();
        while ($table = mysql_fetch_row($result_t)) {
            $REGION[] = $table[0];
        }
    }
    if (is_array($REGION)) {
        foreach ($REGION as $table) {
            $table = trim($table);
            $sql = getSQLbyTableName($table);
コード例 #13
0
console::write('= PHPQuery DATA:');
$folder = console::read('Model Folder (default: /models):>');
console::write('============');
console::write('= DB DATA:');
$host = console::read('Host (default: localhost):>');
$user = console::read('User (default: root):>');
$pass = console::read('Pass (default: null):>');
$dbname = console::read('DB Name (default: test):>');
$folder = empty($folder) ? '/models' : $folder;
$host = empty($host) ? 'localhost' : $host;
$user = empty($user) ? 'root' : $user;
$pass = empty($pass) ? '' : $pass;
$dbname = empty($dbname) ? 'test' : $dbname;
DB::init($host, $user, $pass, $dbname);
$model_location = __DIR__ . '/../..' . $folder . '/';
$models = getTables();
foreach ($models as $newModel) {
    $file = $newModel . '.php';
    if (!file_exists($model_location . $file)) {
        console::write('[+] Model ' . $newModel . ': ', false);
        $data = getTableFields($newModel);
        $fields = $data['fields'];
        $pks = $data['pk'];
        $modelBody = '<?php' . PHP_EOL . PHP_EOL;
        $modelBody .= '// model autogenerated by model_maker.php' . PHP_EOL;
        $modelBody .= 'class ' . $newModel . ' extends table' . PHP_EOL;
        $modelBody .= '{' . PHP_EOL;
        $modelBody .= '    // Primary keys' . PHP_EOL;
        console::write('[pks: ' . count($pks) . '] - ', false);
        if (count($pks) == 1) {
            $modelBody .= '    protected $primaryKeys = \'' . $pks[0] . '\';' . PHP_EOL . PHP_EOL;
コード例 #14
0
function export($base, $generationSimple, $infos, $user, $mdp, $dbh)
{
    //we get the tables
    $resultFindTables = getTables($dbh, $base);
    //echo "<pre>";var_dump($resultFindTables);exit;
    $arrayConstructHierarchy = array();
    //we start the xml menu
    $xmlMenu = new XMLWriter();
    $xmlMenu->openUri($base . "/config/menu.xml");
    $xmlMenu->setIndent(true);
    $xmlMenu->setIndentString("     ");
    $xmlMenu->startDocument("1.0", "UTF-8");
    $xmlMenu->startElement("menu");
    foreach ($resultFindTables as $table) {
        //we empty the xml menu
        $xmlMenu->startElement("aMenu");
        $xmlMenu->writeAttribute("tableName", $table["Tables_in_" . $base . ""]);
        $xmlMenu->writeAttribute("displayName", $table["Tables_in_" . $base . ""]);
        $xmlMenu->endElement();
        //we initialize a var that contains the infos on the table
        $contenu;
        //we empty the variable
        $contenu = getContenu("simple", $table["Tables_in_" . $base . ""]);
        //we search the different relations on the table
        $sqlFindRelations = "SELECT \r\n\t        ke.column_name col, \r\n\t        ke.referenced_table_schema assoc_db,\r\n\t        ke.referenced_table_name assoc_table,\r\n\t        ke.referenced_column_name assoc_col\r\n\t\t    FROM\r\n\t        information_schema.KEY_COLUMN_USAGE ke\r\n\t\t    WHERE\r\n\t        ke.referenced_table_name IS NOT NULL              \r\n\t\t    AND   ke.table_schema='" . $base . "'\r\n\t\t    AND   ke.table_name='" . $table["Tables_in_" . $base . ""] . "'";
        //we searh the different fields on this table
        $sqlReqFindFields = "DESCRIBE " . $table["Tables_in_" . $base . ""] . "";
        $prepaFindFields = $dbh->query($sqlReqFindFields);
        $prepaFindFields->setFetchMode(PDO::FETCH_ASSOC);
        $resultFindFields = $prepaFindFields->fetchAll();
        //we start a variable that will contain the generated code for the declaration of the differents fields in the future class
        $arrayRoutineFields = "";
        //we start the xml configuration of the table we are into in the loop
        $xml = new XMLWriter();
        $xml->openUri($base . "/config/" . $table["Tables_in_" . $base . ""] . ".xml");
        $xml->setIndent(true);
        $xml->setIndentString("     ");
        $xml->startDocument("1.0", "UTF-8");
        $xml->startElement("formDescription");
        $xml->writeAttribute('reqLimit', 10);
        $xml->writeAttribute('formOrder', "");
        //and for each field ...
        foreach ($resultFindFields as $key => $field) {
            //we start a xml field
            $xml->startElement($field['Field']);
            $xml->writeAttribute('isGridVisible', 'true');
            //...
            $xml->writeAttribute('dataType', $field['Type']);
            //...
            //if its not a primary key , we put it in the form, we do a special treatment for the primary keys
            if ($field['Key'] != "PRI") {
                $xml->writeAttribute('isVisibleInForm', 'true');
                //...
                $xml->writeAttribute('isFilterVisible', 'true');
                //...
            } else {
                if ($key == 0) {
                    //if it(s the first, it(s the one that we define has the primary key...))
                    $xml->writeAttribute('isVisibleInForm', 'false');
                    //...
                    $xml->writeAttribute('isPrimaryKey', 'true');
                    //...
                    $xml->writeAttribute('isFilterVisible', 'false');
                    //...
                    /*$xml -> startElement('pushHierarchy');//...
                    			$xml->writeAttribute('className',' a class name');
                    			$xml->writeAttribute('promptLabel',' prompt label');
                    			$xml->writeAttribute('enabled','false');
                    			$xml->writeAttribute('listIcone',' url of an icon');
                    			$xml->writeAttribute('displayColumn','');
                    			$xml->writeAttribute('displayDenomination','');
                    		$xml->endElement();
                    		
                    		$xml -> startElement('getHierarchy');//...
                    			$xml->writeAttribute('className',' a class name');
                    			$xml->writeAttribute('promptLabel',' prompt label');
                    			$xml->writeAttribute('enabled','false');
                    		$xml->endElement();*/
                } else {
                    //else maybe it's a foreign key so we put a display column label ...
                    $xml->writeAttribute('isVisibleInForm', 'true');
                    //...
                    $xml->writeAttribute('isFilterVisible', 'true');
                    //...
                    $xml->writeComment("in case of forein key , we can specify the column we choose to display datas ..??");
                    //comment
                    $xml->startElement('displayColumn');
                    $xml->writeAttribute('sortColumn', '');
                    $xml->text('');
                    $xml->endElement();
                }
            }
            //label diplayed in the forms
            $xml->writeComment('label displayed in the form');
            $xml->writeElement("label", $field['Field']);
            //maybe it's a foreign key so we put a display column label ...
            if ($field['Key'] == "MUL") {
                $xml->writeComment("in case of forein key , we can specify the column we choose to display datas ..??");
                $xml->startElement('displayColumn');
                $xml->writeAttribute('sortColumn', '');
                $xml->text('');
                $xml->endElement();
            }
            //type of checking
            $xml->writeComment('type of checking for the field : simple,mail,optional,int');
            $xml->writeElement("cheking", "");
            //*******************************************picture upload**************************************************************//
            //infos
            $xml->writeComment('if you want to upload picture , you have to fill the infos in this node , if the enabled attribute is set to true, the configuration will work');
            $xml->startElement("pictureField");
            $xml->writeAttribute("enabled", "false");
            $xml->writeAttribute("enabledForRelation", "false");
            $xml->writeComment('each child node represents a saving of the picture, resizeType can be set to resizeFix, resizeHomo, resizeHomoW, resizeHomoH, noResize; the path attribute is the path of the uploaded pictures, it must be relative to the index.php file of the admin directory wich is created and need end slash');
            $xml->startElement("picture");
            $xml->writeAttribute("resizeType", "type of resizing");
            $xml->writeAttribute("width", "width in pixels");
            $xml->writeAttribute("height", "height in pixels");
            $xml->writeAttribute("ratio", "height in pixels");
            $xml->writeAttribute("path", "path for the picture");
            $xml->writeAttribute("isForAdmin", "false");
            //accepted formats
            $xml->startElement("acceptedFormats");
            $xml->writeComment('each child node represents a format of picture');
            $xml->writeElement("format", ".jpg");
            $xml->endElement();
            $xml->endElement();
            $xml->endElement();
            //*********************************************************************************************************//
            //*******************************************file upload**************************************************************//
            //infos
            $xml->writeComment('if you want to upload files , you have to fill the infos in this node , if the enabled attribute is set to true, the configuration will work');
            $xml->startElement("fileField");
            $xml->writeAttribute("enabled", "false");
            $xml->writeComment('configuration for the upload');
            $xml->startElement("aFile");
            //$xml -> writeComment('the path attribute is the path of the uploaded file, it must be relative to the index.php file of the admin directory wich is created and need end slash');
            //$xml -> writeAttribute("path", "path for the file");
            $xml->writeAttribute("path", "path for the file");
            $xml->writeComment('each child node represents an accepted format');
            //accepted formats
            $xml->startElement("acceptedFormats");
            $xml->writeElement('format', '.extension');
            $xml->endElement();
            $xml->endElement();
            $xml->endElement();
            //*********************************************************************************************************//
            //date fields
            $xml->writeComment('the informations can be a date... in this case we save a timestamp in the bdd');
            $xml->startElement("dateField");
            $xml->writeAttribute("enabled", "false");
            $xml->endElement();
            //boolean fields
            $xml->writeComment('the informations can be a boolean... in this case we save a tinyint in the bdd');
            $xml->startElement("booleanField");
            $xml->writeAttribute("enabled", "false");
            $xml->writeElement("boolean_true_label", "oui");
            $xml->writeElement("boolean_false_label", "non");
            $xml->endElement();
            //riche editor field
            $xml->writeComment('the informations can be text, so we can implement a rich text editor, format can be dd/mm/yyyy or mm/dd/yyyy ');
            $xml->startElement("richTextEditorField");
            $xml->writeAttribute("enabled", "false");
            $xml->endElement();
            //riche editor field
            $xml->writeComment('if you want to make a colorpicker field');
            $xml->startElement("colorPickerField");
            $xml->writeAttribute("enabled", "false");
            $xml->endElement();
            //we empty this variable that contains the generated code for the declaration of the differents fields in the future class
            $arrayRoutineFields .= '
				$this->arrayFields["' . $field['Field'] . '"]=array
				(
					"type"=>"' . $field['Type'] . '",
					"canBeNull"=>"' . $field['Null'] . '",
					"key"=>"' . $field['Key'] . '",
					"default"=>"' . $field['Default'] . '",
					"extra"=>"' . $field['Extra'] . '",
					"formLabel"=>"' . $field['Field'] . '"
				);
			';
            $xml->endElement();
        }
        $xml->writeComment('this node contains all the callbacks for the differents action on this model ');
        $xml->startElement("callbacks");
        $xml->writeComment('action that is executed when an element is saved');
        $xml->startElement('onSave');
        $xml->writeAttribute('fileName', '');
        $xml->writeAttribute('className', '');
        $xml->writeAttribute('methodName', '');
        $xml->endElement();
        $xml->startElement('onDelete');
        $xml->writeAttribute('fileName', '');
        $xml->writeAttribute('className', '');
        $xml->writeAttribute('methodName', '');
        $xml->endElement();
        $xml->startElement('onUpdate');
        $xml->writeAttribute('fileName', '');
        $xml->writeAttribute('className', '');
        $xml->writeAttribute('methodName', '');
        $xml->endElement();
        $xml->endElement();
        $xml->endElement();
        $xml->endDocument();
        $xml->flush();
        // done for the xml of the model and the cruds
        //this query is used to find all the relation for the table in the loop
        $prepaFindRelations = $dbh->query($sqlFindRelations);
        $prepaFindRelations->setFetchMode(PDO::FETCH_ASSOC);
        $resultFindRelations = $prepaFindRelations->fetchAll();
        $arrayConstructHierarchy[$table["Tables_in_" . $base . ""]] = $resultFindRelations;
        $arrayRelations = "";
        //$xmlHierarchy->startElement($table["Tables_in_" . $base . ""]);
        foreach ($resultFindRelations as $relation) {
            $arrayRelations .= '
				$this->arrayRelations["' . $relation["col"] . '"]=array
				(
					"assoc_table"=>"' . $relation["assoc_table"] . '",
					"assoc_col"=>"' . $relation["assoc_col"] . '"
				);
			';
        }
        //$xmlHierarchy->endElement();
        //we empty some variables
        $newContent = str_replace("{arrayFieldRoutine}", $arrayRoutineFields, $contenu);
        $newContent = str_replace("{arrayRelations}", $arrayRelations, $newContent);
        //we empty some files ...
        file_put_contents($base . "/model/" . $table["Tables_in_" . $base . ""] . ".php", $newContent);
        //models
        file_put_contents($base . "/libs/php/inclusion_" . $table["Tables_in_" . $base . ""] . ".php", '<?php $datasManager=new ' . $table["Tables_in_" . $base . ""] . 'DatasManager(); $oneElement=new ' . $table["Tables_in_" . $base . ""] . '(); ?>');
        // inclusion files
        file_put_contents($base . "/libs/php/inclusion_bididi.php", '<?php
				$infos="' . $infos . '";
				$user="******";
				$mdp="' . $mdp . '";
				$dbh=new PDO($infos,$user,$mdp,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
		     ?>');
        //database definition
    }
    $xmlMenu->endElement();
    $xmlMenu->endDocument();
    $xmlMenu->flush();
    //	done for the xml of the backend menu
    //we create a xml for the global labels, formats etc
    $xmlGlobalConfig = new XMLWriter();
    $xmlGlobalConfig->openUri($base . "/config/global_config.xml");
    $xmlGlobalConfig->setIndent(true);
    $xmlGlobalConfig->setIndentString("     ");
    $xmlGlobalConfig->startDocument("1.0", "UTF-8");
    $xmlGlobalConfig->startElement("global_config");
    $xmlGlobalConfig->startElement("generic");
    $xmlGlobalConfig->writeElement("global_date_format", "dd-mm-yy");
    $xmlGlobalConfig->writeElement("global_add_label", "Ajouter un élément");
    $xmlGlobalConfig->writeElement("global_filter_label", "Filtres");
    $xmlGlobalConfig->writeElement("global_search_label", "Rechercher");
    $xmlGlobalConfig->writeElement("global_delete_confirm_label", "Etes vous sur de vouloir effacer cet élément ?");
    $xmlGlobalConfig->writeElement("global_delete_label", "effacer");
    $xmlGlobalConfig->writeElement("global_edit_label", "éditer");
    $xmlGlobalConfig->writeElement("global_edit_title_label", "Modifier l'élement");
    $xmlGlobalConfig->writeElement("global_add_title_label", "Informations sur l'élement");
    $xmlGlobalConfig->writeElement("global_save_label", "Sauvegarder l'élément");
    $xmlGlobalConfig->writeElement("global_cancel_label", "Annuler");
    $xmlGlobalConfig->writeElement("global_error_image_label", "L'image n'a pu être récupéré");
    $xmlGlobalConfig->writeElement("global_error_file_label", "Le fichier n'a pu être récupéré");
    $xmlGlobalConfig->writeElement("global_error_fields_label", "Vérifiez d'avoir bien rempli les champs surlignés en rouge");
    $xmlGlobalConfig->writeElement("global_login", "login");
    $xmlGlobalConfig->writeElement("global_password", "password");
    $xmlGlobalConfig->writeElement("global_login_label", "Identifiant");
    $xmlGlobalConfig->writeElement("global_password_label", "Mot de passe");
    $xmlGlobalConfig->writeElement("global_wrong_login", "login incorrect");
    $xmlGlobalConfig->writeElement("global_disconnect", "Se déconnecter");
    $xmlGlobalConfig->writeElement("global_connect", "Se connecter");
    $xmlGlobalConfig->endElement();
    $xmlGlobalConfig->endElement();
    $xmlGlobalConfig->endDocument();
    $xmlGlobalConfig->flush();
    //	done
    //we start the hierarchy xml
    $xmlHierarchy = new XMLWriter();
    $xmlHierarchy->openUri($base . "/config/hierarchy.xml");
    $xmlHierarchy->setIndent(true);
    $xmlHierarchy->setIndentString("     ");
    $xmlHierarchy->startDocument("1.0", "UTF-8");
    $xmlHierarchy->startElement("hierarchy");
    $arrayReverseHierarchy = array();
    foreach ($arrayConstructHierarchy as $key => $value) {
        $xmlHierarchy->startElement($key);
        $xmlHierarchy->writeAttribute('refName', $key);
        $xmlHierarchy->writeAttribute('displayColumn', "");
        $xmlHierarchy->startElement("parentTables");
        foreach ($value as $value2) {
            $xmlHierarchy->startElement("parentTable");
            if (!isset($arrayReverseHierarchy[$value2['assoc_table']])) {
                $arrayReverseHierarchy[$value2['assoc_table']] = array();
            }
            $arrayReverseHierarchy[$value2['assoc_table']][] = array("className" => $key, "usedCol" => $value2['assoc_col'], "fk" => $value2['col']);
            $xmlHierarchy->writeAttribute("className", $value2['assoc_table']);
            $xmlHierarchy->writeAttribute("fk", $value2['col']);
            $xmlHierarchy->writeAttribute("usedCol", $value2['assoc_col']);
            $xmlHierarchy->writeAttribute("enabled", "false");
            $xmlHierarchy->writeAttribute("prompt", "");
            $xmlHierarchy->writeAttribute("icon", "");
            //$xmlHierarchy->writeAttribute("refName",$value2['assoc_table']);
            /*foreach($value2 as $key3=>$value3)
            		{
            			$xmlHierarchy->writeAttribute($key3,$value3);
            			
            		}*/
            $xmlHierarchy->endElement();
        }
        $xmlHierarchy->endElement();
        $xmlHierarchy->endElement();
    }
    $xmlHierarchy->endElement();
    $xmlHierarchy->endDocument();
    $xmlHierarchy->flush();
    $xmlAgain = simplexml_load_file($base . "/config/hierarchy.xml");
    //echo "<pre>";var_dump($arrayReverseHierarchy);
    foreach ($arrayReverseHierarchy as $key => $value) {
        $xmlAgain->{"" . $key . ""}->addChild("childTables", "");
        foreach ($value as $key2 => $value2) {
            $xmlAgain->{"" . $key . ""}->childTables->addChild("childTable");
            foreach ($value2 as $key3 => $value3) {
                $xmlAgain->{"" . $key . ""}->childTables->childTable[$key2]->addAttribute($key3, $value3);
            }
            $xmlAgain->{"" . $key . ""}->childTables->childTable[$key2]->addAttribute("enabled", "false");
            $xmlAgain->{"" . $key . ""}->childTables->childTable[$key2]->addAttribute("prompt", "");
            $xmlAgain->{"" . $key . ""}->childTables->childTable[$key2]->addAttribute("icon", "");
            //$xmlAgain->{"".$key.""}->childTables->childTable[$key2]->addAttribute("refName",$key);
        }
    }
    $xmlAgain->asXml($base . "/config/hierarchy.xml");
}
コード例 #15
0
ファイル: database.php プロジェクト: sanluca/py-acqua-hw
function backupTables()
{
    global $ax, $calID, $set, $lcV;
    echo "<fieldset><legend>{$ax['mdb_backup']}</legend>\n";
    //get table names
    $tables = getTables();
    if (empty($tables)) {
        echo "{$ax['mdb_noshow_tables']}\n";
        $result = false;
    } else {
        $sqlFile = backupDatabase($tables, true);
        //create backup file
        //save .sql dump file
        $fName = "./files/{$calID}-dump-" . date('Ymd-His') . '.sql';
        echo "<br>{$ax['mdb_file_name']} <strong>{$fName}</strong><br>\n";
        if (file_put_contents($fName, $sqlFile) !== false) {
            echo "{$ax['mdb_file_saved']}<br>\n";
            $result = basename($fName);
        } else {
            echo "<br><br><strong>{$ax['mdb_write_error']}</strong><br>\n";
            $result = false;
        }
    }
    echo "</fieldset>\n";
    return $result;
}
コード例 #16
0
     return;
 } else {
     $gDb_dst = new BitDb();
 }
 require_once 'create_config_inc.php';
 $createHash = array("gBitDbType" => $_REQUEST['db_dst'], "gBitDbHost" => $tmpHost, "gBitDbUser" => $_REQUEST['user_dst'], "gBitDbPassword" => $_REQUEST['pass_dst'], "gBitDbName" => $_REQUEST['name_dst'], "bit_db_prefix" => $_REQUEST['prefix_dst'], "bit_root_url" => $_REQUEST['baseurl'], "auto_bug_submit" => isset($_REQUEST['auto_bug_submit']) ? 'TRUE' : 'FALSE', "is_live" => isset($_REQUEST['is_live']) ? 'TRUE' : 'FALSE');
 create_config($createHash);
 // init db connections
 //vd($gDb_src);
 //vd($gDb_dst);die;
 if ($debug) {
     $gDb_dst->debug();
 }
 // list source tables list
 $tables_src = array($tables_src[2]);
 $tables_dst = getTables($gDb_dst);
 print_r($tables_src);
 die;
 $table_schema = array();
 // iterate through source tables
 foreach ($tables_src as $table) {
     if (array_search($table, $skip_tables) !== FALSE) {
         if ($debug) {
             echo "Skipping {$table}<br>\n";
         }
         continue;
     }
     if ($debug) {
         echo "Creating {$table}<br>\n";
     }
     if ($empty_tables && $gDb_dst->tableExists($table)) {