コード例 #1
0
 public static function count_completed_entries($formid, $name, $email, $file_id, $uid = "")
 {
     global $wpdb;
     $search = array();
     //$query = "SELECT count(*) as count   FROM ".$wpdb->prefix."rg_lead_meta as m LEFT JOIN ".$wpdb->prefix."rg_lead as l ON (l.id=m.lead_id) WHERE m.meta_value='".$uid."' AND m.meta_key = 'is_pending' AND l.status = 'pending'";
     $query = "SELECT count(*) as count FROM " . $wpdb->prefix . "rg_lead as l LEFT JOIN " . $wpdb->prefix . "tpl_docs  as d ON l.id = d.lead_id ";
     $search[] = " created_by = " . wp_get_current_user()->ID . " ";
     $search[] = " l.status = 'active' ";
     $search[] = " l.form_id !=" . TemplateData::edit_profileform_id() . " ";
     if ($formid != NULL) {
         $search[] = " l.form_id =" . $formid . " ";
     }
     if ($file_id != NULL) {
         $search[] = " d.file_id ='" . $file_id . "' ";
     }
     if ($email != NULL) {
         $search[] = " d.email ='" . $email . "' ";
     }
     if ($name != NULL) {
         $search[] = " d.name ='" . $name . "' ";
     }
     if (!empty($search)) {
         $query .= " WHERE " . implode('and', $search);
     }
     $sql = $query;
     return $wpdb->get_var($sql);
 }