$script->shutdown(1); } $whereParamsArray['country'] = $options['country-code']; if ( !$options['new-position'] ) { $cli->output( "[error] option --new-position is missing" ); $script->shutdown(1); } // first : we fetch all the users with this country code $step = 1000; $appid = $options["appid"]; $newPosition = $options["new-position"]; $countryCode = $options["country-code"]; $whereParams = buildWhereParams( $whereParamsArray ); $cli->output( "[notification] start script for user with country $countryCode" ); $queryCount = "SELECT COUNT(*) FROM mm_users $whereParams"; $userCountArray = $db->arrayQuery( $queryCount ); $userCount = $userCountArray[0]["COUNT(*)"]; $cli->output( "[notification] $userCount objects to treat" ); $treated = 0; $page = ceil( $userCount/$step ); for ( $i = 0; $i < $page; $i++ )
$appsInfo = $db->arrayQuery( $query ); $updateSql = array(); $counter = 0; foreach ($appsInfo as $app) { $whereMaxPositionArray = array(); $whereMaxPositionArray['cluster_identifier'] = $app['cluster_identifier']; if( $app['customer_type'] ) $whereMaxPositionArray['customer_type'] = $app['customer_type']; if($app['main_speciality']) $whereMaxPositionArray['main_speciality'] = $app['main_speciality']; if($app['user_profile_id']) $whereMaxPositionArray['user_profile_id'] = $app['user_profile_id']; $whereParams = buildWhereParams( $whereMaxPositionArray ); $sqlGetMaxPosition = 'SELECT MAX(`order`) as max_order FROM mm_country_apps_bar '.$whereParams; $maxPositionArray = $db->arrayQuery( $sqlGetMaxPosition ); $maxPosition = $maxPositionArray[0]['max_order']; $currentPosition = $app['order']; $positionToUpdate = array(); //if app is upadated to last position if( $newPosition == 'last' || $newPosition >= $maxPosition ) { $newPosition = $maxPosition; } if( $currentPosition == $newPosition ) { $cli->warning('Application id "'.$app['id'].'" is already on position '.$currentPosition.' for: "'.$whereParams.'"');