Beispiel #1
0
 function query($query)
 {
     global $wpdb;
     $result = $wpdb->query($query);
     if ($wpdb->last_error) {
         $this->logger->error($wpdb->last_error);
         return false;
     }
     return $result;
 }
Beispiel #2
0
 /** Returns the user identify by an id or an email. If $id_or_email is an object or an array, it is assumed it contains
  * the "id" attribute or key and that is used to load the user.
  *
  * @global type $wpdb
  * @param string|int|object|array $id_or_email
  * @param type $format
  * @return boolean
  */
 function get_user($id_or_email, $format = OBJECT)
 {
     global $wpdb;
     // To simplify the reaload of a user passing the user it self.
     if (is_object($id_or_email)) {
         $id_or_email = $id_or_email->id;
     } else {
         if (is_array($id_or_email)) {
             $id_or_email = $id_or_email['id'];
         }
     }
     $id_or_email = strtolower(trim($id_or_email));
     if (is_numeric($id_or_email)) {
         $r = $wpdb->get_row($wpdb->prepare("select * from " . NEWSLETTER_USERS_TABLE . " where id=%d limit 1", $id_or_email), $format);
     } else {
         $r = $wpdb->get_row($wpdb->prepare("select * from " . NEWSLETTER_USERS_TABLE . " where email=%s limit 1", $id_or_email), $format);
     }
     if ($wpdb->last_error) {
         $this->logger->error($wpdb->last_error);
         return false;
     }
     return $r;
 }