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

  • 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')); } }
  • ok thanks!!
  • $Context->Database->Execute($SQL, 'UserWall', NULL, 'Could not create User Wall table');

    ok what does 'UserWall' do in this part
  • 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#
  • edited December 2006
    I believe that is the name of the object/class that is sending the execute query. (for debugging purposes).
  • but isnt the table name in the $sql also why is it repeated i am confused!
  • ok yeah valentinp is right then.
  • oh lol i did not see his comment. sorry
This discussion has been closed.