Skip to content

Commit a826ddd

Browse files
author
Luke Carbis
committed
Merge pull request #774 from xwp/feature/issue-770
Add helper function to DB class
2 parents 30e1403 + 298cb1e commit a826ddd

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

classes/class-cli.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function query( $args, $assoc_args ) {
111111

112112
$query_args['fields'] = implode( ',', $fields );
113113

114-
$records = wp_stream_get_instance()->db->query->query( $query_args );
114+
$records = wp_stream_get_instance()->db->query( $query_args );
115115

116116
// Make structure Formatter compatible
117117
foreach ( (array) $records as $key => $record ) {
@@ -212,7 +212,7 @@ private function csv_format( $array ) {
212212
* @return void
213213
*/
214214
private function connection() {
215-
$query = wp_stream_get_instance()->db->query->query( array( 'records_per_page' => 1, 'fields' => 'created' ) );
215+
$query = wp_stream_get_instance()->db->query( array( 'records_per_page' => 1, 'fields' => 'created' ) );
216216

217217
if ( ! $query ) {
218218
WP_CLI::error( esc_html__( 'SITE IS DISCONNECTED', 'stream' ) );

classes/class-db.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,17 @@ function existing_records( $column ) {
198198

199199
return isset( $this->plugin->connectors->term_labels[ $column ] ) ? $this->plugin->connectors->term_labels[ $column ] : array();
200200
}
201+
202+
/**
203+
* Helper function for calling $this->query->query()
204+
*
205+
* @see Query->query()
206+
*
207+
* @param array Query args
208+
*
209+
* @return array Stream Records
210+
*/
211+
function query( $args ) {
212+
return $this->query->query( $args );
213+
}
201214
}

classes/class-list-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function get_records() {
204204
$args['records_per_page'] = $this->get_items_per_page( 'edit_stream_per_page', 20 );
205205
}
206206

207-
$items = $this->plugin->db->query->query( $args );
207+
$items = $this->plugin->db->query( $args );
208208

209209
return $items;
210210
}

0 commit comments

Comments
 (0)