Skip to content

Instantly share code, notes, and snippets.

@shannah
Created June 25, 2014 23:06
Show Gist options
  • Save shannah/8fbae9926102176c2939 to your computer and use it in GitHub Desktop.
Save shannah/8fbae9926102176c2939 to your computer and use it in GitHub Desktop.
function beforeLoadResultSet(){
$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