Last active
August 29, 2015 14:03
-
-
Save shannah/a0a738874c4f08df0bba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import('xf/db/DynamicTable.php'); | |
$contact_call_info = new \xf\db\DynamicTable("contact_call_info", | |
array( | |
"create table contact_call_info ( | |
contact_id INT(11) NOT NULL PRIMARY KEY, | |
num_calls INT(5), | |
last_call_result VARCHAR(100), | |
last_call_time DATETIME, | |
last_student_decision INT(11), | |
last_mentor_pref INT(11), | |
combined_caller_comments TEXT) | |
", | |
"INSERT INTO contact_call_info select c.contact_id, | |
(select count(*) from calls where contact_id=c.contact_id) as num_calls, | |
(select call_result from calls where contact_id=c.contact_id order by time_of_call desc limit 1) as last_call_result, | |
(select max(time_of_call) from calls where contact_id=c.contact_id) as last_call_time, | |
(select student_decision from calls where contact_id=c.contact_id order by time_of_call desc limit 1) as last_student_decision, | |
(select mentor_preference_id from calls where contact_id=c.contact_id order by time_of_call desc limit 1) as last_mentor_pref, | |
(select group_concat(caller_comments) from calls where contact_id=c.contact_id) as combined_caller_comments | |
from current_call_list c" | |
), | |
array( | |
"calls", | |
"caller_comments" | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment