public static function generate($tableName, array $updateIds = []) { if (!isset(self::$tables[$tableName])) { CLISetup::log('SqlGen::generate - invalid table given', CLISetup::LOG_ERROR); return false; } if (!empty(self::$tables[$tableName][0])) { $tbl = self::$tables[$tableName]; // shorthand CLISetup::log('SqlGen::generate() - copying ' . $tbl[0] . '.dbc into aowow_' . $tableName); $dbc = new DBC($tbl[0], CLISetup::$tmpDBC); if ($dbc->error) { return false; } $dbcData = $dbc->readArbitrary($tbl[1]); foreach ($dbcData as $row) { DB::Aowow()->query('REPLACE INTO ?_' . $tableName . ' (?#) VALUES (?a)', array_keys($row), array_values($row)); } return !!$dbcData; } else { if (file_exists('setup/tools/sqlgen/' . $tableName . '.func.php')) { $customData = $reqDBC = []; CLISetup::log('SqlGen::generate() - filling aowow_' . $tableName . ' with data'); require_once 'setup/tools/sqlgen/' . $tableName . '.func.php'; if (function_exists($tableName)) { // check for required auxiliary DBC files foreach ($reqDBC as $req) { if (!CLISetup::loadDBC($req)) { return false; } } $success = $tableName($updateIds); // apply post generator custom data foreach ($customData as $id => $data) { if ($data) { DB::Aowow()->query('UPDATE ?_' . $tableName . ' SET ?a WHERE id = ?d', $data, $id); } } } else { CLISetup::log(' - subscript \'' . $tableName . '\' not defined in included file', CLISetup::LOG_ERROR); } return $success; } else { CLISetup::log(sprintf(ERR_MISSING_INCL, $tableName, 'setup/tools/sqlgen/' . $tableName . '.func.php'), CLISetup::LOG_ERROR); } } }