/** * Crea le tabelle se non esistono (backup se l'SQL non funziona) */ private function checkAndCreateTables() { $db = JFactory::getDbo(); // Tabella spedizioni $tableName = $db->quoteName('#__hikashop_packlink_shipments'); $db->setQuery("SHOW TABLES LIKE " . $db->quote($db->replacePrefix('#__hikashop_packlink_shipments'))); $exists = $db->loadResult(); if (!$exists) { $query = "CREATE TABLE IF NOT EXISTS $tableName ( id INT(11) NOT NULL AUTO_INCREMENT, order_id INT(11) NOT NULL, shipment_id VARCHAR(100) NOT NULL, warehouse_id INT(11) NOT NULL, service_name VARCHAR(255) DEFAULT NULL, status VARCHAR(50) DEFAULT 'created', created DATETIME NOT NULL, modified DATETIME DEFAULT NULL, PRIMARY KEY (id), KEY idx_order_id (order_id), KEY idx_shipment_id (shipment_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; $db->setQuery($query); $db->execute(); } // Tabella cache $tableName = $db->quoteName('#__hikashop_packlink_cache'); $db->setQuery("SHOW TABLES LIKE " . $db->quote($db->replacePrefix('#__hikashop_packlink_cache'))); $exists = $db->loadResult(); if (!$exists) { $query = "CREATE TABLE IF NOT EXISTS $tableName ( id INT(11) NOT NULL AUTO_INCREMENT, cache_key VARCHAR(255) NOT NULL, cache_data TEXT NOT NULL, created DATETIME NOT NULL, expires DATETIME NOT NULL, PRIMARY KEY (id), UNIQUE KEY idx_cache_key (cache_key) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; $db->setQuery($query); $db->execute(); } } /** * Chiama la creazione tabelle all'inizializzazione */ public function onAfterInitialise() { $this->checkAndCreateTables(); }
Per installare questa Web App nel tuo iPhone/iPad premi l'icona.
E poi Aggiungi alla schermata principale.