Beispiel #1
0
/**
*¨[type] file
* [name] record_add.php
* [package] psa
* [since] 2012.02.12
* [expl] 
*/
# TODO: submit and cmd
$submit->setValue('Update');
$cmd->setValue('edit_do');
/**/
$sql = new LitePDO('sqlite:' . $sessie->getS('psa-dir') . '/' . $sessie->getS('psa-db') . '.' . $sessie->getS('psa-ext') . '');
$q = "PRAGMA table_info('" . $req->get('table') . "')";
$sql->qo($q);
$res = $sql->fo();
$pk = false;
foreach ($res as $item) {
    if ($item->name == 'id') {
        $pk = true;
    }
    $col[] = $item->name;
}
if ($pk) {
    $q = "SELECT * FROM " . $req->get('table') . " WHERE id = " . $req->get('id');
} else {
    $q = "SELECT * FROM " . $req->get('table') . " WHERE ROWID = " . $req->get('id');
}
$sql->qo($q);
$res = $sql->fo_one();
// var_dump($res);
Beispiel #2
0
<?php

/**
 * [type] file
 * [name] tableinfo.php
 * [package] psa
 * [since] 2010.10.20
 */
$sql = new LitePDO('sqlite:' . $sessie->getS('psa-dir') . '/' . $sessie->getS('psa-db') . '.' . $sessie->getS('psa-ext') . '');
$q = "PRAGMA table_info('" . $req->get('table') . "')";
$sql->qo($q);
$res = $sql->fo();
// var_dump($res);
$html = new Page();
$html->setLanguage('nl_NL');
$html->build();
$head = new Head();
$head->setCharset('UTF-8');
$head->setTitle('PSA - show table info for ' . $req->get('table'));
$head->setCss('./css/psa.css');
$head->setJs('./js/PSA.js');
$head->build();
$body = new Body();
$body->build();
include_once './inc/menubar.php';
$body->line('<h3>Structure for table : <b>' . $req->get('table') . '</b></h3>');
$table = new Table();
$table->setClas('result');
$table->setId('listing');
$table->build();
$th = new Th();
Beispiel #3
0
    $colnull = $req->get('colnull');
    $colsize = $req->get('colsize');
    $coldefault = $req->get('coldefault');
    $q = "INSERT INTO temp_table_fields (\n\t\ttblname\n\t\t,colname\n\t\t,coltype\n\t\t,colprime\n\t\t,colnull\n\t\t,colsize\n\t\t,coldefault)\n\t\tVALUES (\n\t\t:tblname\n\t\t,:colname\n\t\t,:coltype\n\t\t,:colprime\n\t\t,:colnull\n\t\t,:colsize\n\t\t,:coldefault)";
    $ajax_sql->binder('tblname', $tblname);
    $ajax_sql->binder('colname', $colname);
    $ajax_sql->binder('colprime', $colprime);
    $ajax_sql->binder('coltype', $coltype);
    $ajax_sql->binder('colnull', $colnull);
    $ajax_sql->binder('colsize', $colsize);
    $ajax_sql->binder('coldefault', $coldefault);
    $ajax_sql->qo($q);
    // DEBUG: var_dump($ajax_sql);
    $q = "SELECT * FROM temp_table_fields";
    $ajax_sql->qo($q);
    $res = $ajax_sql->fo();
    $tab = '<table>';
    $tab .= '<thead>
		<th>name</th>
		<th>type</th>
		<th>size</th>
		<th>prime</th>
		<th>null</th>
		<th>default</th>
		</thead><tbody>';
    foreach ($res as $item) {
        $tab .= '
			<tr><td>' . $item->colname . '</td><td>' . $item->coltype . '</td><td>' . $item->colsize . '</td><td>' . $item->colprime . '</td><td>' . $item->colnull . '</td><td>' . $item->coldefault . '</td><td><a href="#" onclick="PSA.tablerow_delete(' . $item->id . ');"><button>delete</button></a>' . '</td></tr>';
    }
    $tab .= '</tbody></table>';
    echo $tab;
Beispiel #4
0
* [type] file
* [name] drop_column.php
* [package] psa
* [since] 2012.01.21
* [expl] action file !!
*/
/*
$req->dump();
echo '<hr />';
*/
$sql = new LitePDO('sqlite:' . $sessie->getS('psa-dir') . '/' . $sessie->getS('psa-db') . '.' . $sessie->getS('psa-ext') . '');
// get list of existing columns
// copy to temp leaving out the column to be deleted
$q = "PRAGMA table_info('" . $req->get('table') . "')";
$sql->qo($q);
$rescols = $sql->fo();
if (sizeof($rescols) === 1) {
    $q = "DROP TABLE " . $req->get('table') . " ";
    $sql->qo($q);
    $sessie->setS('psa-error', 'Table "' . $req->get('table') . '" dropped. No more columns');
    header('location: controller.php?cmd=table');
    exit;
}
$string = '';
$begin = true;
$colums = '';
foreach ($rescols as $item) {
    if ($item->name === $req->get('col')) {
        continue;
    }
    /* DEBUG: echo '<hr>';
Beispiel #5
0
if ($req->is('db')) {
    if ($req->get('db') == '') {
        $sessie->setS('psa-error', 'No database set.');
        header('location: controller.php?cmd=base');
        exit;
    }
    $sessie->setS('psa-db', urldecode($req->get('db')));
}
// PAGING
if (!$sessie->isS('bottom')) {
    $sessie->setS('bottom', 0);
}
$sql = new LitePDO('sqlite:' . $sessie->getS('psa-dir') . '/' . $sessie->getS('psa-db') . '.' . $sessie->getS('psa-ext') . '');
$q = "SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name";
$sql->qo($q);
$res = $sql->fo();
// echo "BOTTOM WAARDE  : <b><h1>".$sessie->getS('bottom')."</h1></b>";
$html = new Page();
$html->setLanguage('nl_NL');
$html->build();
$head = new Head();
$head->setCharset('UTF-8');
$head->setTitle('PSA - database schema');
$head->setCss('./css/psa.css', 'screen');
$head->setCss('./css/psaprint.css', 'print');
$head->setjs('./js/PSA.js');
$head->build();
$body = new Body();
$body->build();
include_once './inc/menubar.php';
if (!$res) {