Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N
mysql asterisk -u cron -p1234 -e "UPDATE vicidial_list SET status='DNC' WHERE status='AFTHRS' and list_id='997'"
geoff3dmg wrote:Also remember that MySQL/MariaDB has a built in scheduler (I'm using it to reset my ADCT/ADC statuses nightly).
DROP EVENT `Reset ADCT Leads`;
CREATE DEFINER=`root`@`localhost` EVENT `Reset ADCT Leads` ON SCHEDULE EVERY 1 DAY STARTS '2014-01-01 03:00:00' ON COMPLETION NOT PRESERVE ENABLE DO
UPDATE asterisk.vicidial_list as vl
INNER JOIN asterisk.vicidial_log as vlog ON vl.lead_id=vlog.lead_id AND vl.last_local_call_time=vlog.call_date
INNER JOIN asterisk.vicidial_campaigns as vc ON vc.campaign_id=vlog.campaign_id
SET vl.status = 'ADCT'
WHERE vlog.status = 'ADCT' and vl.status = 'ADC' and vl.called_count <= vc.call_count_limit
mysql -u cron -p1234 asterisk -e "select user,pass,active from vicidial_users where user_level='9'"
* * * * * mysql -u cron -p1234 asterisk -e "select user,pass,active from vicidial_users where user_level='9'"
<?PHP
define('DEBUG', false);
define('CLIDISPLAY', false);
if (CLIDISPLAY) {
define('PRE', '');
define('PRE_END', '');
} else {
define('PRE', '<pre>');
define('PRE_END', '</pre>');
}
require_once("../vicidial/dbconnect.php");
$DBLink = new mysqli($VARDB_server, $VARDB_user, $VARDB_pass, $VARDB_database, $VARDB_port);
if ($DBLink->connect_errno) {
printf(PRE . "Connect failed: %s\n" . PRE_END, $DBLink->connect_error);
exit();
}
# Sample execution
$Query = "select * from vicidial_users where user='6666' and active='Y' limit 1";
$Records = GetData($DBLink, $Query);
print_r($Records[0]); // Single record return access via [0] to access a field named "id": $Records[0]['id']
// Multiple record return access via array walking
foreach ($Records as $Record) {
print_r($Record);
}
$Query = "update vicidial_users set active='Y' where user='6666' limit 1";
UpdateData($DBLink, $Query);
#Functions
function GetData($DBLink, $Query) {
if (DEBUG) {
echo PRE . "Query: $Query\n" . PRE_END;
}
if ($Result = $DBLink->query($Query)) {
if (DEBUG) {
printf(PRE . "Affected rows (Non-Select): %d\n" . PRE_END, $DBLink->affected_rows);
}
while ($Record = $Result->fetch_assoc()) {
$ReturnData[] = $Record;
}
return $ReturnData;
} else {
if (DEBUG) {
printf(PRE . "Errormessage: %s\n", $DBLink->error);
printf("Affected rows (Non-Select): %d\n", $DBLink->affected_rows);
echo "No Records Returned\n" . PRE_END;
}
return false;
}
}
function UpdateData($DBLink, $Query) {
if (DEBUG) {
echo PRE . "Query: $Query\n" . PRE_END;
}
if ($Result = $DBLink->query($Query)) {
if (DEBUG) {
printf(PRE . "%s\n", $DBLink->info);
printf("Affected rows (Non-Select): %d\n" . PRE_END, $DBLink->affected_rows);
}
return;
} else {
if (DEBUG) {
printf(PRE . "Errormessage: %s\n", $DBLink->error);
printf("Affected rows (Non-Select): %d\n", $DBLink->affected_rows);
echo "No Records Returned\n" . PRE_END;
}
return;
}
}
Users browsing this forum: Google [Bot] and 66 guests