WP_CLI\Iterators

Table::build_where_conditions()private staticWP-CLI 1.0

Method of the class: Table{}

No Hooks.

Return

null. Nothing.

Usage

$result = Table::build_where_conditions( $where );
$where (required)
-

Table::build_where_conditions() code WP-CLI 2.8.0-alpha

private static function build_where_conditions( $where ) {
	global $wpdb;
	if ( is_array( $where ) ) {
		$conditions = [];
		foreach ( $where as $key => $value ) {
			if ( is_array( $value ) ) {
				$conditions[] = $key . ' IN (' . esc_sql( implode( ',', $value ) ) . ')';
			} elseif ( is_numeric( $key ) ) {
				$conditions[] = $value;
			} else {
				$conditions[] = $key . $wpdb->prepare( ' = %s', $value );
			}
		}
		$where = implode( ' AND ', $conditions );
	}
	return $where;
}