. */ namespace SP\Core\Upgrade; use SP\Storage\DbWrapper; use SP\Storage\QueryData; /** * Class Check * @package SP\Core\Upgrade */ class Check { /** * Comprobar si hay conflictos para aplicar las restricciones * * @return mixed */ public static function checkConstraints() { $query = /** @lang SQL */ 'SELECT * FROM (SELECT COUNT(*) AS accounts_user FROM Account WHERE account_userId NOT IN (SELECT user_id FROM usrData) OR account_userId IS NULL) au, (SELECT COUNT(*) AS accounts_group FROM Account WHERE account_userGroupId NOT IN (SELECT usergroup_id FROM usrGroups) OR account_userGroupId IS NULL) ag, (SELECT COUNT(*) AS accounts_useredit FROM Account WHERE account_userEditId NOT IN (SELECT user_id FROM usrData) OR account_userEditId IS NULL) b, (SELECT COUNT(*) AS accounts_category FROM Account WHERE account_categoryId NOT IN (SELECT id FROM Category) OR account_categoryId IS NULL) c, (SELECT COUNT(*) AS accounts_customer FROM Account WHERE account_customerId NOT IN (SELECT id FROM customers) OR account_customerId IS NULL) d, (SELECT COUNT(*) AS accountshistory_user FROM accHistory WHERE acchistory_userId NOT IN (SELECT user_id FROM usrData) OR acchistory_userId IS NULL) eu, (SELECT COUNT(*) AS accountshistory_group FROM accHistory WHERE acchistory_userGroupId NOT IN (SELECT usergroup_id FROM usrGroups) OR acchistory_userGroupId IS NULL) eg, (SELECT COUNT(*) AS accountshistory_useredit FROM accHistory WHERE acchistory_userEditId NOT IN (SELECT user_id FROM usrData) OR acchistory_userEditId IS NULL) f, (SELECT COUNT(*) AS accountshistory_category FROM accHistory WHERE acchistory_categoryId NOT IN (SELECT id FROM Category) OR acchistory_categoryId IS NULL) g, (SELECT COUNT(*) AS accountshistory_customer FROM accHistory WHERE acchistory_customerId NOT IN (SELECT id FROM customers) OR acchistory_customerId IS NULL) h, (SELECT COUNT(*) AS users_group FROM usrData WHERE user_groupId NOT IN (SELECT usergroup_id FROM usrGroups) OR user_groupId IS NULL) i, (SELECT COUNT(*) AS users_profile FROM usrData WHERE user_profileId NOT IN (SELECT id FROM UserProfile) OR user_profileId IS NULL) j'; $Data = new QueryData(); $Data->setQuery($query); return DbWrapper::getResults($Data); } }