En cours

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.

<?php

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';

$rent->save();

$rent->load_relationship('msk_rent_accounts');

$rent->msk_rent_accounts->add($account->id);

}

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';

$rent->save();

$rent->load_relationship('msk_rent_accounts');

$rent->msk_rent_accounts->add($account->id);

}

}

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

return true;

}

?>

Compétences : MySQL, PHP

Voir plus : working home fee, sugarcrm project module, rent pdf, rent mysql database, foreach php mysql, example php program, code line, code 8, late work, modify pdf file, php code program, type pdf files, type code, think debug, php fatal error, php debug, optimize mysql, interact, globals, garbage one, code name one, true pdf file, php database project pdf, optimize php code, fatal error php

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

N° du projet : #2400451

Décerné à :

chienthuatxd

I can do it very quick, please pm for me

50 $ USD en 0 jours
(30 Commentaires)
4.7

6 freelance ont fait une offre moyenne de 157 $ pour ce travail

prominentsoft

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

250 $ USD en 10 jours
(80 Commentaires)
6.1
appsolution

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

40 $ USD en 1 jour
(0 Commentaires)
0.0
AA2Fe4z8H

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

250 $ USD en 1 jour
(0 Commentaires)
0.0
jcgo810326

I can do this....

250 $ USD en 2 jours
(0 Commentaires)
0.0
wordpressphp

Accept bid and give me job u will get result.

100 $ USD en 3 jours
(0 Commentaires)
0.0