예제 #1
0
 /**
  * Find matching objects.
  */
 function query()
 {
     $sql = new SQLGenerator($this->example->getCore());
     $ds = $this->example->datasource;
     $sb = $this->example->storage_method->config->copyObject();
     if (!is_null($this->joinedExamples)) {
         foreach ($this->joinedExamples as $je) {
             $sb->joinTo($je->storage_method->config, TRUE);
         }
     }
     $ds->connect();
     $res = $ds->query($sql->select($sb, $this->getCore()));
     $cs =& $res->getNext();
     $rv = array();
     while ($cs) {
         $score =& $cs->getCore();
         assert(is_array($score));
         $clone = $this->example;
         // copy
         $clone->is_loaded = TRUE;
         $clone->set($score);
         $rv[] = $clone;
         $cs =& $res->getNext();
     }
     return $rv;
 }
예제 #2
0
 /**
  * @brief Converting this table into SQL INSERTs queries.
  * @return string SQL query for this table
  */
 public function toSql()
 {
     $sql_generator = new SQLGenerator();
     // Class for generating SQL from tables
     return $sql_generator->tableToSQL($this);
     // Converting this table on SQL queries
 }
예제 #3
0
 public function generateSQL()
 {
     Makiavelo::info("Generating SQL statements...");
     $sql_gen = new SQLGenerator($this->en_name, $this->en_attributes);
     $create_database_sql = $sql_gen->create_database_sql();
     $create_db_file = ROOT_PATH . Makiavelo::SQL_CREATE_TABLES_FOLDER . "/create_db.sql";
     if (!file_exists($create_db_file)) {
         $fp = fopen($create_db_file, "w");
         if ($fp) {
             Makiavelo::info("Create db saved");
             fwrite($fp, $create_database_sql);
             fclose($fp);
         }
     }
     $create_sql = $sql_gen->create_sql();
     $create_table_file = ROOT_PATH . Makiavelo::SQL_CREATE_TABLES_FOLDER . "/" . $this->en_name . ".sql";
     if (!file_exists($create_table_file)) {
         $fp = fopen($create_table_file, "w");
         if ($fp) {
             Makiavelo::info("Create table saved");
             fwrite($fp, $create_sql);
             fclose($fp);
         }
     }
     $crud_sql = $sql_gen->crud_sql();
     Makiavelo::info("Generating SQL CRUD: ");
     Makiavelo::info(print_r($crud_sql, true));
     $template_helper_file = ROOT_PATH . Makiavelo::TEMPLATES_FOLDER . "/sql_helper_templates.php";
     $fp = fopen($template_helper_file, "r");
     if ($fp) {
         $template_code = fread($fp, filesize($template_helper_file));
         $code = str_replace("[NAME]", $this->en_name, $template_code);
         $code = str_replace("[UC_NAME]", Makiavelo::camel_to_underscore($this->en_name), $code);
         foreach ($crud_sql as $action => $query) {
             $code = str_replace("[" . strtoupper($action) . "_SQL]", $query, $code);
         }
         fclose($fp);
         //Saving template
         $helper_file = ROOT_PATH . Makiavelo::SQL_HELPERS_FOLDER . "/" . $this->en_name . ".php";
         if (!file_exists($helper_file)) {
             $fp = fopen($helper_file, "w");
             if ($fp) {
                 Makiavelo::info("Helper sql file saved");
                 fwrite($fp, $code);
                 fclose($fp);
             }
         }
     }
     Makiavelo::info("CRUD SQL created: " . print_r($crud_sql, true));
 }
예제 #4
0
 public static function addSQL($table)
 {
     $conn = self::setConnection();
     $sql = SQLGenerator::SQLToAdd($table);
     if ($conn->query($sql) === TRUE) {
     } else {
         echo "Error: " . $conn->error;
     }
     $conn->close();
 }
<?php 
set_time_limit(300);
ini_set("memory_limit", "2500M");
require_once 'Configuration.php';
require_once 'Classes/SQLGenerator.Class.php';
new SQLGenerator($FCCore['DataDirectory'] . $FCCore['English548'], $FCCore['Locale']);
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_achievementcategory` VALUES', SQLGenerator::Unpack("Achievement_Category.dbc", "nisx"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_achievement` VALUES', SQLGenerator::Unpack("Achievement.dbc", "niiissiiiiisiix"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_achievementcriteria` VALUES', SQLGenerator::Unpack("Achievement_Criteria.dbc", "niiiiiiiisxxxxxxxxxxxxxxxxiixii"));  --- Unknown fields | Not Working !!!!!
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_glyphproperties` VALUES', SQLGenerator::Unpack("GlyphProperties.dbc", "niii"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_items', SQLGenerator::Unpack("Item.db2", "niixiiii")); --- DB2 File | Not Working !!!!!
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_char_titles` (id,name_loc0) VALUES', SQLGenerator::Unpack("CharTitles.dbc", "nxsxxx"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_item_extended_cost` VALUES', SQLGenerator::Unpack("ItemExtendedCost.dbc", "niixiiiiiiiiiiix")); --- DB2 File | Not Working !!!!!
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_skill_line_ability` VALUES', SQLGenerator::Unpack("SkillLineAbility.dbc", "xiiiixxixxiixx"));  --- Unknown fields | Not Working !!!!!
// Connection RESET FFS !!!!! SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_skill` VALUES', SQLGenerator::Unpack("SkillLine.dbc", "nixsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_spelldispeltype` VALUES', SQLGenerator::Unpack("SpellDispelType.dbc", "nsxxx"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_spellmechanic` VALUES', SQLGenerator::Unpack("SpellMechanic.dbc", "ns"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_resistances` VALUES', SQLGenerator::Unpack("Resistances.dbc", "nxxs"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_spellcasttimes` VALUES', SQLGenerator::Unpack("SpellCastTimes.dbc", "nixx"));
//SQLGenerator::PrintSQL('<br />', SQLGenerator::RemovePath(SQLGenerator::Unpack("SpellIcon.dbc", "ns")));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_lock` VALUES', SQLGenerator::Unpack("Lock.dbc", "niiiiixxxiiiiixxxiiiiixxxxxxxxxxx"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_icons` VALUES', SQLGenerator::Unpack("ItemDisplayInfo.dbc", "nxxxxsxxxxxxxxxxxxxxxxxxxx"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_itemset` VALUES', SQLGenerator::Unpack("ItemSet.dbc", "nsiiiiiiiiiixxxxxxxiiiiiiiiiiiiiiiiii"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_spell` VALUES', SQLGenerator::Unpack("Spell.dbc", "niiixxxxxxxxxxxxxxxxxxxxxxxxiixxiixiixxiixixxxixxiiiiiiiiiiiiiiiiiiixxxiiiiiixxxiiixxxiiiiiiiiiiiiiiifffiiiiiiiiixxxiiifffxxxxxxxxxxxixxsxxxxxxxxxxxxxxxxsxxxxxxxxxxxxxxxxsxxxxxxxxxxxxxxxxsxxxxxxxxxxxxxxxxixxixxxxixxxfffxxxxxxxxxxxxxxx")); -- NOT YET PARSED!!!!
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_spellduration` VALUES', SQLGenerator::Unpack("SpellDuration.dbc", "nixx"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_spellrange` VALUES', SQLGenerator::Unpack("SpellRange.dbc", "nffffxsx"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_spellradius` VALUES', SQLGenerator::Unpack("SpellRadius.dbc", "nfxxx"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_itemenchantmet` VALUES', SQLGenerator::Unpack("SpellItemEnchantment.dbc", "nxxxxxxxxxxsxxxxxxxxxxxxxx"));
//SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_gemproperties` VALUES', SQLGenerator::Unpack("GemProperties.dbc", "nixxxx"));
SQLGenerator::PrintSQL('<br />INSERT INTO `freedomhead_talent` VALUES', SQLGenerator::Unpack("Talent.dbc", "niiiiiiiixxxxixxixxxxix"));
	ADD COLUMN `tooltip_loc<?php 
echo $L;
?>
` text NOT NULL AFTER `tooltip_loc0`,
	ADD COLUMN `buff_loc<?php 
echo $L;
?>
` text NOT NULL AFTER `buff_loc0`;
ALTER TABLE freedomhead_talenttab ADD COLUMN `name_loc<?php 
echo $L;
?>
` varchar(32) NOT NULL AFTER `name_loc0`;


<?php 
SQLGenerator::PrintUpdate('', SQLGenerator::Unpack("Achievement_Category.dbc", SQLGenerator::Localize("nxSxxxxxxxxxxxxxxxxx"), true), array(0 => "id"), array(1 => "name_loc{$L}"));
SQLGenerator::PrintUpdate('freedomhead_achievement', SQLGenerator::Unpack("Achievement.dbc", SQLGenerator::Localize("nxxxSxxxxxxxxxxxxxxxxSxxxxxxxxxxxxxxxxxxxxxSxxxxxxxxxxxxxxxxxx"), true), array(0 => "id"), array(1 => "name_loc{$L}", 2 => "description_loc{$L}", 3 => "reward_loc{$L}"));
SQLGenerator::PrintUpdate('freedomhead_achievementcriteria', SQLGenerator::Unpack("Achievement_Criteria.dbc", SQLGenerator::Localize("nxxxxxxxxSxxxxxxxxxxxxxxxxxxxxx"), true), array(0 => "id"), array(1 => "name_loc{$L}"));
SQLGenerator::PrintUpdate('freedomhead_char_titles', SQLGenerator::Unpack("CharTitles.dbc", SQLGenerator::Localize("nxSxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), true), array(0 => "id"), array(1 => "name_loc{$L}"));
SQLGenerator::PrintUpdate('freedomhead_skill', SQLGenerator::Unpack("SkillLine.dbc", SQLGenerator::Localize("nxxSxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), true), array(0 => "skillID"), array(1 => "name_loc{$L}"));
SQLGenerator::PrintUpdate('freedomhead_spelldispeltype', SQLGenerator::Unpack("SpellDispelType.dbc", SQLGenerator::Localize("nSxxxxxxxxxxxxxxxxxxx"), true), array(0 => "id"), array(1 => "name_loc{$L}"));
SQLGenerator::PrintUpdate('freedomhead_spellmechanic', SQLGenerator::Unpack("SpellMechanic.dbc", SQLGenerator::Localize("nSxxxxxxxxxxxxxxxx"), true), array(0 => "id"), array(1 => "name_loc{$L}"));
SQLGenerator::PrintUpdate('freedomhead_resistances', SQLGenerator::Unpack("Resistances.dbc", SQLGenerator::Localize("nxxSxxxxxxxxxxxxxxxx"), true), array(0 => "id"), array(1 => "name_loc{$L}"));
SQLGenerator::PrintUpdate('freedomhead_itemset', SQLGenerator::Unpack("ItemSet.dbc", SQLGenerator::Localize("nSxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), true), array(0 => "itemsetID"), array(1 => "name_loc{$L}"));
SQLGenerator::PrintUpdate('freedomhead_spellrange', SQLGenerator::Unpack("SpellRange.dbc", SQLGenerator::Localize("nxxxxxSxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), true), array(0 => "rangeID"), array(1 => "name_loc{$L}"));
SQLGenerator::PrintUpdate('freedomhead_zones', SQLGenerator::Unpack("AreaTable.dbc", SQLGenerator::Localize("nxxxxxxxxxxSxxxxxxxxxxxxxxxxxxxxxxxx"), true), array(0 => "areatableID"), array(1 => "name_loc{$L}"));
SQLGenerator::PrintUpdate('freedomhead_factions', SQLGenerator::Unpack("Faction.dbc", SQLGenerator::Localize("nxxxxxxxxxxxxxxxxxxxxxxSxxxxxxxxxxxxxxxxSxxxxxxxxxxxxxxxx"), true), array(0 => "factionID"), array(1 => "name_loc{$L}", 2 => "description1_loc{$L}"));
SQLGenerator::PrintUpdate('freedomhead_itemenchantmet', SQLGenerator::Unpack("SpellItemEnchantment.dbc", SQLGenerator::Localize("nxxxxxxxxxxxxxSxxxxxxxxxxxxxxxxxxxxxxx"), true), array(0 => "itemenchantmetID"), array(1 => "text_loc{$L}"));
// HTTP SERVER ERROR!!!!!!!! SQLGenerator::PrintUpdate('freedomhead_spell', SQLGenerator::Unpack("Spell.dbc", SQLGenerator::Localize("nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxSxxxxxxxxxxxxxxxxSxxxxxxxxxxxxxxxxSxxxxxxxxxxxxxxxxSxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), true), array(0=>"spellID"), array(1=>"spellname_loc$L", 2=>"rank_loc$L", 3=>"tooltip_loc$L", 4=>"buff_loc$L"));
SQLGenerator::PrintUpdate('freedomhead_talenttab', SQLGenerator::Unpack("TalentTab.dbc", SQLGenerator::Localize("nSxxxxxxxxxxxxxxxxxxxxxx"), true), array(0 => "id"), array(1 => "name_loc{$L}"));
//SQLGenerator::PrintUpdate('', SQLGenerator::Unpack(".dbc", SQLGenerator::Localize(""), true), );
 public static function MapGenerator($DBCArray)
 {
     $FinalDBC = array();
     $MapDBC = $DBCArray[0][0];
     $MapFormat = $DBCArray[0][1];
     $AreaDBC = $DBCArray[1][0];
     $AreaFormat = $DBCArray[1][1];
     $WorldMapDBC = $DBCArray[2][0];
     $WorldMapFormat = $DBCArray[2][1];
     $MapType = array();
     $AreaType = array();
     $TempDBC = SQLGenerator::Unpack($MapDBC, $MapFormat, true);
     foreach ($TempDBC as $Row) {
         $MapType[$Row[0]] = $Row[1];
         if ($Row[3]) {
             $AreaType[$Row[0] . "@" . $Row[3]] = $Row[1];
         }
     }
     $TempDBC = SQLGenerator::Unpack($AreaDBC, $AreaFormat, true);
     foreach ($TempDBC as $Row) {
         $Type = 0;
         if (isset($maptype[$Row[1]])) {
             $Type = $maptype[$Row[1]];
         }
         if (isset($areatype[$Row[1] . "@" . $Row[0]])) {
             $Type = $areatype[$Row[1] . "@" . $Row[0]];
         }
         $FinalDBC[$Row[0]] = array($Row[1], $Row[0], $Row[2], 0, 0, 0, 0, $Type);
     }
     $TempDBC = SQLGenerator::Unpack($WorldMapDBC, $WorldMapFormat, true);
     foreach ($TempDBC as $Row) {
         if (isset($FinalDBC[$Row[1]])) {
             $FinalDBC[$Row[1]][3] = $Row[5] < $Row[6] ? $Row[5] : $Row[6];
             $FinalDBC[$Row[1]][4] = $Row[3] < $Row[4] ? $Row[3] : $Row[4];
             $FinalDBC[$Row[1]][5] = $Row[5] < $Row[6] ? $Row[6] : $Row[5];
             $FinalDBC[$Row[1]][6] = $Row[3] < $Row[4] ? $Row[4] : $Row[3];
         }
     }
     unset($TempDBC);
     echo base64_decode(SQLGenerator::GetHeader('Group.dbc'));
     return $FinalDBC;
 }
예제 #8
0
 /**
  * Remove an object.
  * @param ChunsuObject $removeme The object to remove.
  * @param DataSource $source The data source to remove the object from.
  * @return bool TRUE is successful, FALSE otherwise.
  */
 function remove(&$removeme, $source)
 {
     parent::remove($removeme, $source);
     $gen = new SQLGenerator($removeme->getCore());
     $removequeries = $gen->delete($this->config);
     foreach ($removequeries as $rq) {
         $cursor =& $source->query($rq);
         $rv = $cursor->getNext();
         if (!$rv) {
             LogError("remove query failed! removing " . print_r($removeme, TRUE));
             return FALSE;
         }
     }
     $rv = $cursor->getNext();
     if (!$rv) {
         LogError("Remove failed! Removing " . print_r($removeme, TRUE));
         return FALSE;
     }
     if ($rows = $cursor->get('affected-rows') > 1) {
         LogWarning("{$rows} records deleted removing " . print_r($removeme, TRUE));
     }
     $removeme->is_new = $removeme->config->get('create-on-save');
     return TRUE;
 }