Example #1
0
$db = new Database();
$db->connect();
// Import External SQL File
echo "Import External SQL File";
echo "<br />------------------<br />";
$sqlFile = file_get_contents('src/example.sql');
$db->import($sqlFile);
$response = $db->getResponse();
echo $response[0] == TRUE ? 'TRUE' : 'FALSE';
echo "<br/><br/>";
$db->disconnect();
$db->connect();
// Get all Tables in your Database
echo "Get all Tables in your Database";
echo "<br />------------------<br />";
$db->tables();
$response = $db->getResponse();
for ($x = 0; $x < count($response); $x++) {
    echo $response[$x] . "<br/>";
}
echo "<br/><br/>";
// Get Full Table
echo "Get Full Table";
echo "<br />------------------<br />";
$db->sql('SELECT * FROM users');
$response = $db->getResponse();
foreach ($response as $row) {
    echo $row["username"] . "<br />";
    echo $row["email"] . "<br />";
    echo $row["first_name"] . "<br />";
    echo $row["last_name"] . "<br />";
Example #2
0
<?php

require_once "{$dir}/server/config.php";
require_once "{$dir}/server/database/database.php";
// Load the database
$db_filename = '';
if (preg_match('#sqlite://(.+)#', $db_path, $matches)) {
    list(, $db_filename) = $matches;
}
$db = new Database($db_path);
if ($db->tables() == array()) {
    // Setup the initial database configuration
    $db->setup("{$dir}/server/init.sql");
    $db->query("\n    INSERT INTO user\n    (username, status)\n    VALUES ('shiftspace', 1)\n  ");
}
// Set up the user session
session_register('user');
$user = $_SESSION['user'];
if (empty($user) && !empty($_COOKIE['auth'])) {
    list($username, $password) = explode(':', $_COOKIE['auth']);
    $user = $db->row("\n    SELECT *\n    FROM user\n    WHERE username = '******'\n    AND password = '******'\n  ");
    if (!empty($user)) {
        $_SESSION['user'] = $user;
    }
}
if (!empty($_GET['v'])) {
    $client_version = $_GET['v'];
}
$server = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . '/';
if (get_magic_quotes_gpc()) {
    function strip_quotes(&$var)
Example #3
0
foreach ($results as $item) {
    ?>
        <tr>
            <td><?php 
    echo $item->getId();
    ?>
</td>
            <td><?php 
    echo $item->getTble();
    ?>
</td>
            <td><?php 
    echo $item->getKlass();
    ?>
</td>
            <td><?php 
    echo $item->getLabel();
    ?>
</td>
        </tr>
<?php 
}
print_r(Database::fields(Database::tables()[1]));
?>
    </tbody>
</table>

<?php 
#页脚
//////////////////////////////////////////////////////////////////////////////////////////////
include_once "include/footer.php";
Example #4
0
 /**
  * @return array
  */
 public static function getTables()
 {
     if (!isset(Database::$tables)) {
         $tables = Database::query("SHOW TABLES");
         Database::$tables = array();
         foreach ($tables as $table) {
             array_push(Database::$tables, array_pop($table));
         }
     }
     return Database::$tables;
 }