'migrationpro_data', 'primary' => 'id_data', 'fields' => array( 'type' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true), 'source_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), 'local_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true) ), ); public static function exist($typeString, $sourceId) { $type = constant("self::TYPE_" . Tools::strtoupper($typeString)); if (!is_null($type)) { return Db::getInstance()->getValue( 'SELECT 1 FROM ' . _DB_PREFIX_ . 'migrationpro_data WHERE type=\'' . pSQL($type) . '\' AND source_id=' . (int)$sourceId ); } return false; } public static function import($typeString, $sourceID, $localID) { $type = constant("self::TYPE_" . Tools::strtoupper($typeString)); $sql = 'INSERT INTO ' . _DB_PREFIX_ . 'migrationpro_data SET type=\'' . pSQL($type) . '\', source_id=' . (int)$sourceID . ', local_id=' . (int)$localID . ' ON DUPLICATE KEY UPDATE local_id=' . (int)$localID; return Db::getInstance()->execute($sql); } public static function getLocalID($typeString, $sourceID) { $type = constant("self::TYPE_" . Tools::strtoupper($typeString)); $sql = 'SELECT local_id FROM ' . _DB_PREFIX_ . 'migrationpro_data WHERE type=\'' . pSQL($type) . '\' AND source_id=' . (int)$sourceID . ';'; $result = Db::getInstance()->getValue($sql); // if (!$result) { // return (int)$sourceID; // } return $result; } }