Example #1
0
<?php

$table = 'SH_TABLE_GLOBAL';
if (in_array(constant($table), $TABLE_LIST)) {
    $ok = null;
    table_Init($table);
    switch ($TABLE_VERSION) {
        case 0:
            echo "Creating Table...\n";
            $ok = table_Create($table, "CREATE TABLE " . SH_TABLE_PREFIX . constant($table) . " (\n\t\t\t\tid " . DB_TYPE_UID . ",\n\t\t\t\t`key` " . DB_TYPE_ASCII(64) . " DEFAULT '',\n\t\t\t\t\tINDEX(`key`),\n\t\t\t\t`value` " . DB_TYPE_UNICODE(128) . " DEFAULT '',\n\t\t\t\ttimestamp " . DB_TYPE_TIMESTAMP . "\n\t\t\t)" . DB_CREATE_SUFFIX);
            if (!$ok) {
                break;
            }
            $TABLE_VERSION++;
        case 1:
            $ok = table_Nop($table);
            if (!$ok) {
                break;
            }
            $TABLE_VERSION++;
    }
    // Because this is Global, we do a few more things //
    $global_default = array_merge($SH_GLOBAL_DEFAULT, array_fill_keys(global_GetTableConstants(), 0));
    // Add elements found in the defaults that don't exist yet //
    $global_diff = array_diff_key($global_default, $SH);
    $global_diff_count = count($global_diff);
    if ($global_diff_count > 0) {
        print "Adding " . $global_diff_count . " missing element(s) to " . $table . "\n";
        foreach ($global_diff as $key => $value) {
            print "  * " . $key . " = " . (is_string($value) ? "\"" . $value . "\"\n" : $value . "\n");
            global_Set($key, $value);
Example #2
0
    //		1,1,				// parent, author
    //		'users','','',		// type, subtype, subsubtype
    //		0,0,0,				// published, created, modified
    //		0,					// version
    //		'users','Users',	// slug, name
    //		''					// body
    //	);
}
// Simliar to the regular NODE, but a snapshot
$table = 'SH_TABLE_NODE_VERSION';
if (in_array(constant($table), $TABLE_LIST)) {
    $ok = null;
    table_Init($table);
    switch ($TABLE_VERSION) {
        case 0:
            $ok = table_Create($table, "CREATE TABLE " . SH_TABLE_PREFIX . constant($table) . " (\n\t\t\t\tid " . DB_TYPE_UID . ",\n\t\t\t\tnode " . DB_TYPE_ID . ",\n\t\t\t\t\tINDEX(node),\n\t\t\t\tauthor " . DB_TYPE_ID . ",\n\t\t\t\ttype " . DB_TYPE_ASCII(24) . ",\n\t\t\t\tsubtype " . DB_TYPE_ASCII(24) . ",\n\t\t\t\tsubsubtype " . DB_TYPE_ASCII(24) . ",\n\t\t\t\ttimestamp " . DB_TYPE_TIMESTAMP . ",\n\t\t\t\tslug " . DB_TYPE_ASCII(96) . ",\n\t\t\t\t\tINDEX(slug),\n\t\t\t\tname " . DB_TYPE_UNICODE(96) . ",\n\t\t\t\tbody MEDIUMTEXT NOT NULL,\n\t\t\t\ttag " . DB_TYPE_ASCII(32) . "\n\t\t\t)" . DB_CREATE_SUFFIX);
            if (!$ok) {
                break;
            }
            $TABLE_VERSION++;
    }
    table_Exit($table);
}
$table = 'SH_TABLE_NODE_LINK';
if (in_array(constant($table), $TABLE_LIST)) {
    $ok = null;
    table_Init($table);
    switch ($TABLE_VERSION) {
        case 0:
            $ok = table_Create($table, "CREATE TABLE " . SH_TABLE_PREFIX . constant($table) . " (\n\t\t\t\tid " . DB_TYPE_UID . ",\n\t\t\t\ta " . DB_TYPE_ID . ",\n\t\t\t\t\tINDEX(a),\n\t\t\t\tb " . DB_TYPE_ID . ",\n\t\t\t\t\tINDEX(b),\n\t\t\t\ttype " . DB_TYPE_ASCII(24) . ",\n\t\t\t\t\tINDEX(type)\n\t\t\t)" . DB_CREATE_SUFFIX);
            if (!$ok) {
Example #3
0
    table_Exit($table);
}
$table = 'SH_TABLE_THEME_FINAL_VOTE';
if (in_array(constant($table), $TABLE_LIST)) {
    $ok = null;
    table_Init($table);
    switch ($TABLE_VERSION) {
        case 0:
            $ok = table_Create($table, "CREATE TABLE " . SH_TABLE_PREFIX . constant($table) . " (\n\t\t\t\tid " . DB_TYPE_UID . ",\n\t\t\t\tuser " . DB_TYPE_ID . ",\n\t\t\t\t\tINDEX(user),\n\t\t\t\tnode " . DB_TYPE_ID . ",\n\t\t\t\t\tINDEX(node),\n\t\t\t\t\tUNIQUE `user_node` (user,node),\n\t\t\t\ttimestamp " . DB_TYPE_TIMESTAMP . ",\n\t\t\t\tvalue INT NOT NULL,\n\t\t\t\t\tINDEX (value)\n\t\t\t)" . DB_CREATE_SUFFIX);
            if (!$ok) {
                break;
            }
            $TABLE_VERSION++;
    }
    table_Exit($table);
}
// *** //
$table = 'SH_TABLE_THEME_HISTORY';
if (in_array(constant($table), $TABLE_LIST)) {
    $ok = null;
    table_Init($table);
    switch ($TABLE_VERSION) {
        case 0:
            $ok = table_Create($table, "CREATE TABLE " . SH_TABLE_PREFIX . constant($table) . " (\n\t\t\t\tid " . DB_TYPE_UID . ",\n\t\t\t\tnode " . DB_TYPE_ID . ",\n\t\t\t\tshorthand " . DB_TYPE_ASCII(20) . ",\n\t\t\t\tname " . DB_TYPE_UNICODE(64) . ",\n\t\t\t\ttheme " . DB_TYPE_UNICODE(64) . "\n\t\t\t)" . DB_CREATE_SUFFIX);
            if (!$ok) {
                break;
            }
            $TABLE_VERSION++;
    }
    table_Exit($table);
}