[Vtigercrm-developers] 600_610.php migration script...
Alan Lord
alanslists at gmail.com
Wed Nov 19 15:12:48 GMT 2014
Toward the end of the migration routine is this little gem of a piece of
code ;-)
> //Data migrate from old columns to new columns in vtiger_pbxmanager
> $query = 'SELECT * FROM vtiger_pbxmanager';
> $result = $adb->pquery($query, array());
> $params = array();
> $rowCount = $adb->num_rows($result);
> for ($i = 0; $i < $rowCount; $i++) {
> $pbxmanagerid = $adb->query_result($result, $i, 'pbxmanagerid');
> $callfrom = $adb->query_result($result, $i, 'callfrom');
> $callto = $adb->query_result($result, $i, 'callto');
> $timeofcall = $adb->query_result($result, $i, 'timeofcall');
> $status = $adb->query_result($result, $i, 'status');
> $customer = PBXManager_Record_Model::lookUpRelatedWithNumber($callfrom);
> $userIdQuery = $adb->pquery('SELECT userid FROM vtiger_asteriskextensions WHERE asterisk_extension = ?', array($callto));
> $user = $adb->query_result($userIdQuery, $i, 'userid');
> if ($status == 'outgoing') {
> $callstatus = 'outbound';
> } else if ($status == 'incoming') {
> $callstatus = 'inbound';
> }
In my pbxmanager table I have over 400,000 records... In the callto
column is that abomination of an idea where it stores stuff like this:
> <a href='index.php?module=Leads&action=DetailView&record=67865'>Guy ??</a>
Now then. In the code snippet above, there is a line that reads:
> $customer = PBXManager_Record_Model::lookUpRelatedWithNumber($callfrom);
That function lookUpRelatedWithNumber() will *never* return a $customer
array because there is no phone number in the callto column - there is a
href with a crmid...
What on earth was the idea behind this?
Has anyone already written a regex parser to extract the crmid and
modulename from the callto string so I can write a function that will
actually do something useful with my 400,000 records?
Al
More information about the vtigercrm-developers
mailing list