insert( $table, array( 'log_id' => $log_id, 'meta_key' => $meta_key, 'meta_value' => $meta_value, ), array( '%d', '%s', '%s' ) ); // phpcs:enable WordPress.DB.DirectDatabaseQuery, WordPress.DB.SlowDBQuery.slow_db_query_meta_key, WordPress.DB.SlowDBQuery.slow_db_query_meta_value } /** * Read all meta values for a key on a log row, oldest-first. * * @param int $log_id Log row id. * @param string $meta_key Key to read. * * @return string[] */ public static function get_all( int $log_id, string $meta_key ): array { if ( $log_id <= 0 || '' === $meta_key ) { return array(); } global $wpdb; $table = Installer::table( 'log_meta' ); // phpcs:disable WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter $rows = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM {$table} WHERE log_id = %d AND meta_key = %s ORDER BY id ASC", $log_id, $meta_key ) ); // phpcs:enable WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared return array_map( 'strval', is_array( $rows ) ? $rows : array() ); } }