Fresh code drop

Bind values in raw queries

PHP

Original CodeSnap example inspired by Laravel News. Source: https://laravel-news.com/eloquent-tips-tricks

PHP
CodeSnap // free canvas

Bind values in raw queries

<?php

$orders = Order::query()
    ->whereRaw(
        'total > CASE WHEN state = ? THEN ? ELSE ? END',
        ['TX', 200, 100],
    )
    ->get();

// Further reading: https://laravel-news.com/eloquent-tips-tricks

Turn your code into a post.Five templates are free—no account needed.

Remix this snap