guagualai/query-builder-helper

組出 SQL 語法以及把參數帶上去

dev-master 2023-12-14 03:44 UTC

This package is auto-updated.

Last update: 2024-04-14 04:29:29 UTC


README

QueryBuilderHelper is a PHP package designed to work with Laravel's Eloquent query builder. It provides a convenient way to get the raw SQL query along with its bindings, which can be useful for debugging and logging.

Installation

You can install the package via composer:

composer require guagualai/query-builder-helper

Usage

Here's a simple example of how to use QueryBuilderHelper:

use Guagualai\QueryBuilderHelper\SqlHelper;
use Illuminate\Database\Eloquent\Model;

class YourModel extends Model
{
    // Your model's methods...
}

$query = YourModel::where('column', 'value')->getQuery();
$sqlWithBindings = SqlHelper::getWithBindings($query);

echo $sqlWithBindings;

This will output the raw SQL query with the bindings included, making it easier to see the actual query that will be run against the database.

License

The MIT License (MIT). Please see License File for more information.