Modify PHP code to better interact with MySQL so that PHP consumes less memory

I have written a custom module for SugarCRM. The module works great when there is minimal data being computed from the database. Over the last 6 months our database has grown. And now my module uses too much memory and I'm getting the following error from several parts of the module:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 87 bytes) in /home/millpond/public_html/crm_live/data/[url removed, login to view] on line 638

I can no longer simply allocate more memory to the program. So I need someone to go through the module and optimize it to do less PHP calculations and rather do more MySQL calculations. Furthermore, I think that SugarCRM is not letting some of my objects be collected by the PHP garbage collection. So with each iteration, my memory requirements grows.

Understand that although you don't need to know SugarCRM to do this work it will likely be helpful. When you bid this please tell me how well you know SugarCRM.

There are four main functionalities that will have to be looked at. Each function is generally spread out over several several files (about 8 in total):

Charge Monthly Late Fee

Charge Monthly Rent

Update Address & Phone

Update Company & Balance

I've attached a file that contains all of the custom code that may need to be reviewed. The pdf folder does not contain custom code. If you work on this project, you will get the full working module which contains a lot of additional code that is part of SugarCRM.

Below is example of one of the charge rent function. You can see that much of this code could be executed within my MySQL database. Furthermore, I want to make sure that with each iteration of an account we are freeing the memory of the previous account.


function ChargeRent(){

$GLOBALS['log']->debug('Starting the ChargeRent() function.');

$account = new Account();

$accounts = $account->get_full_list();

foreach($accounts as $account) {

$units = $account->get_linked_beans('msk_unit_accounts', 'msk_unit');

foreach($units as $unit) {

$rentLevel = $unit->get_linked_beans('msk_rentlvl_msk_unit', 'msk_rentlvl');

$rent = new msk_Rent();

$rent->name = strftime("%B's Rent for $unit->name");

$rent->amount = $rentLevel[0]->monthly_rent * -1;

$rent->type = 'Rent';





if($account->monthly_rent_adjustment_c != 0) {

$rent = new msk_Rent();

$rent->name = strftime("%B's Rent Adjustment");

$rent->amount = $account->monthly_rent_adjustment_c * -1;

$rent->type = 'Adjustment';






$GLOBALS['log']->debug('ChargeRent() function is complete.');

return true;



Compétences : MySQL, PHP

en voir plus : working from home no fee, sugarcrm project module, rent pdf, rent code, rent a mysql database, php on line 87, late to work, id to code, how to work out from home, go to rent, foreach in php and mysql, example of php program, code line, code 8, being late to work, how to modify pdf file, php code program, type from some pdf files, type code, think debug, the better me, php function , php fatal error, php debug, optimize mysql

Concernant l'employeur :
( 22 commentaires ) Forest Lake, United States

Nº du projet : #2400451

Décerné à:


I can do it very quick, please pm for me

%selectedBids___i_sum_sub_7% %project_currencyDetails_sign_sub_8% USD en 0 jours
(30 Commentaires)

6 freelance font une offre moyenne de $157 pour ce travail


I have high skills on PHP/MySQL. I can optimize your code for better performance.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 10 jours
(80 Commentaires)

i can provide you the solution. please message me for further discussion.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(0 Commentaires)

Custom software development (<b><i>Removed by Admin</i></b>)

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(0 Commentaires)

I can do this....

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 2 jours
(0 Commentaires)

Accept bid and give me job u will get result.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 3 jours
(0 Commentaires)