Code Explainers

Code explainers tagged #sql

php
public function customerTotals(Request $request): Collection
{
    return DB::table('orders')
        ->join('customers', 'customers.id', '=', 'orders.customer_id')

Building an aggregate report with Laravel's query builder

query builder aggregation conditional queries
Intermediate 8 steps
java
public class KeysetPaginationRepository {
 
    private final DataSource dataSource;
 

How keyset pagination works in Java

pagination sql jdbc
Intermediate 8 steps
go
func (r *EventRepository) BatchInsert(ctx context.Context, events []Event) error {
	if len(events) == 0 {
		return nil
	}

Batch inserting rows in a Go transaction

transactions batching database
Intermediate 7 steps
php
<?php
 
namespace App\Database;
 

Building a fluent SQL query builder in PHP

fluent-interface method-chaining sql
Intermediate 10 steps
php
<?php
 
final class ProductRepository
{

Safe SQL pagination with PDO in PHP

pagination input-validation prepared-statements
Intermediate 7 steps