| @@ 151-180 (lines=30) @@ | ||
| 148 | * |
|
| 149 | * @return bool|null|array |
|
| 150 | */ |
|
| 151 | public function get_comment_by( $comment_id = 0, $by = 'id' ) { |
|
| 152 | /* @var WPDB $wpdb */ |
|
| 153 | global $wpdb; |
|
| 154 | $comment = null; |
|
| 155 | ||
| 156 | // Make sure $comment_id is int. |
|
| 157 | $comment_id = absint( $comment_id ); |
|
| 158 | ||
| 159 | // Bailout. |
|
| 160 | if ( empty( $comment_id ) ) { |
|
| 161 | return null; |
|
| 162 | } |
|
| 163 | ||
| 164 | switch ( $by ) { |
|
| 165 | case 'id': |
|
| 166 | $comment = $wpdb->get_row( |
|
| 167 | $wpdb->prepare( |
|
| 168 | "SELECT * FROM $this->table_name WHERE ID = %s LIMIT 1", |
|
| 169 | $comment_id |
|
| 170 | ), |
|
| 171 | ARRAY_A |
|
| 172 | ); |
|
| 173 | break; |
|
| 174 | ||
| 175 | default: |
|
| 176 | $comment = apply_filters( "give_get_comment_by_{$by}", $comment, $comment_id ); |
|
| 177 | } |
|
| 178 | ||
| 179 | return $comment; |
|
| 180 | } |
|
| 181 | ||
| 182 | /** |
|
| 183 | * Retrieve comments from the database. |
|
| @@ 151-180 (lines=30) @@ | ||
| 148 | * |
|
| 149 | * @return bool|null|array |
|
| 150 | */ |
|
| 151 | public function get_log_by( $log_id = 0, $by = 'id' ) { |
|
| 152 | /* @var WPDB $wpdb */ |
|
| 153 | global $wpdb; |
|
| 154 | $log = null; |
|
| 155 | ||
| 156 | // Make sure $log_id is int. |
|
| 157 | $log_id = absint( $log_id ); |
|
| 158 | ||
| 159 | // Bailout. |
|
| 160 | if ( empty( $log_id ) ) { |
|
| 161 | return null; |
|
| 162 | } |
|
| 163 | ||
| 164 | switch ( $by ) { |
|
| 165 | case 'id': |
|
| 166 | $log = $wpdb->get_row( |
|
| 167 | $wpdb->prepare( |
|
| 168 | "SELECT * FROM $this->table_name WHERE ID = %s LIMIT 1", |
|
| 169 | $log_id |
|
| 170 | ), |
|
| 171 | ARRAY_A |
|
| 172 | ); |
|
| 173 | break; |
|
| 174 | ||
| 175 | default: |
|
| 176 | $log = apply_filters( "give_get_log_by_{$by}", $log, $log_id ); |
|
| 177 | } |
|
| 178 | ||
| 179 | return $log; |
|
| 180 | } |
|
| 181 | ||
| 182 | /** |
|
| 183 | * Retrieve logs from the database. |
|