Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N
###############################################################################
###### third traverse array of remote agents to be active and insert or update
###### in vicidial_live_agents table
###############################################################################
$h=0;
foreach(@DBremote_user)
{
if (length($DBremote_user[$h])>1)
{
### check to see if the record exists and only needs random number update
$stmtA = "SELECT count(*) FROM vicidial_live_agents where user='$DBremote_user[$h]' and server_ip='$server_ip' and campaign_id='$DBremote_campaign[$h]' and conf_exten='$DBremote_conf_exten[$h]' and closer_campaigns='$DBremote_closer[$h]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$loginexistsRANDOM[$h] = "$aryA[0]";
$rec_count++;
}
$sthA->finish();
if ($loginexistsRANDOM[$h] > 0)
{
$stmtA = "UPDATE vicidial_live_agents set random_id='$DBremote_random[$h]' where user='$DBremote_user[$h]' and server_ip='$server_ip' and campaign_id='$DBremote_campaign[$h]' and conf_exten='$DBremote_conf_exten[$h]' and closer_campaigns='$DBremote_closer[$h]';";
$affected_rows = $dbhA->do($stmtA);
if ($DBX) {print STDERR "$DBremote_user[$h] $DBremote_campaign[$h] ONLY RANDOM ID UPDATE: $affected_rows\n";}
}
}
else
{
$stmtA = "UPDATE vicidial_live_agents set random_id='$VD_random[$z]',last_call_finish='$SQLdate',lead_id='',uniqueid='',callerid='',channel='' where user='$VD_user[$z]' and server_ip='$server_ip';";
$affected_rows = $dbhA->do($stmtA);
if ($DB) {print STDERR "$VD_user[$z] CALL WIPE UPDATE: $affected_rows|READY|$VD_uniqueid[$z]|$VD_user[$z]|\n";}
$stmtA = "UPDATE vicidial_live_agents set status='READY' where user='$VD_user[$z]' and server_ip='$server_ip';";
$affected_rows = $dbhA->do($stmtA);
if ($DB) {print STDERR "$VD_user[$z] CALL WIPE UPDATE: $affected_rows|READY|$VD_uniqueid[$z]|$VD_user[$z]|\n";}
"UPDATE vicidial_live_agents set random_id='$VD_random[$z]', status='READY', last_call_finish='$SQLdate', lead_id='', uniqueid='', callerid='', channel='' where user='$VD_user[$z]' and server_ip='$server_ip';";
DBI connect('asterisk:192.168.1.28:3306','cron',...) failed: Too many connections at /var/lib/asterisk/agi-bin/agi-VDADtransfer.agi line 97
Couldn't connect to database: Too many connections at /var/lib/asterisk/agi-bin/agi-VDADtransfer.agi line 97.
Users browsing this forum: No registered users and 147 guests