Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

How does this code work and what does it do?

y2kbgy2kbg New
edited December 2006 in Vanilla 1.0 Help
if (!array_key_exists('USER_WALL_SCHEMA_VERSION', $Context->Configuration)) {
$SQL = file_get_contents($Context->Configuration['EXTENSIONS_PATH'] . 'UserWall/userwall-mysql.sql');
$Context->Database->Execute($SQL, 'UserWall', NULL, 'Could not create User Wall table');
if ($Context->ErrorManager->Iif()) {
AddConfigurationSetting($Context, 'USER_WALL_SCHEMA_VERSION', '1.0');
} else {
$Context->WarningCollector->Add($Context->GetDefinition('UserWallCreateTableError'));
}
}

I want make an extension that involves making a table, i see how it references the external file for the query but how does it know if the table has already been made?

Comments

  • Options
    ok, I have commented on it.. enjoy
    // checks to see if "USER_WALL_SCHEMA_VERSION" has been added to the settings file. // If it isnt there then it will run the sql table files. Ie make the database tables. if (!array_key_exists('USER_WALL_SCHEMA_VERSION', $Context->Configuration)) { $SQL = file_get_contents($Context->Configuration['EXTENSIONS_PATH'] . 'UserWall/userwall-mysql.sql'); $Context->Database->Execute($SQL, 'UserWall', NULL, 'Could not create User Wall table'); //Checks for errors if ($Context->ErrorManager->Iif()) { // If there were no errors it adds "USER_WALL_SCHEMA_VERSION" to the settings file AddConfigurationSetting($Context, 'USER_WALL_SCHEMA_VERSION', '1.0'); // Otherwise it adds an error saying that the table could not be created or something } else { $Context->WarningCollector->Add($Context->GetDefinition('UserWallCreateTableError')); } }
  • Options
    ok thanks!!
  • Options
    $Context->Database->Execute($SQL, 'UserWall', NULL, 'Could not create User Wall table');

    ok what does 'UserWall' do in this part
  • Options
    edited December 2006
    err by any chance is that the name of the table that is being created its hard to tell without downloading it all#
  • Options
    edited December 2006
    I believe that is the name of the object/class that is sending the execute query. (for debugging purposes).
  • Options
    but isnt the table name in the $sql also why is it repeated i am confused!
  • Options
    ok yeah valentinp is right then.
  • Options
    oh lol i did not see his comment. sorry
This discussion has been closed.