Coder Social home page Coder Social logo

eloquent-dumper's Introduction

Eloquent Dumper

Install

composer install

composer require recca0120/eloquent-dumper

publish config

php artisan vendor:publish --tag="eloquent-dumper"

Config

when you use sqlite in PHPUnit and you need MySQL version sql, you can set driver to mysql, it will output MySQL version sql

// eloquent-dumper.php
return [
    /*
     * Supported: "pdo", "mysql", "sqlite", "pgsql", "sqlsrv"
     */
    'driver' => env('ELOQUENT_DUMPER_GRAMMAR', 'pdo'),
];

How to use

var_dump(
    User::where('name', 'foo')
        ->where('password', 'bar')
        ->sql()
);

User::where('name', 'foo')
    ->where('password', 'bar')
    ->dumpSql()
    ->get();

// output:
// SELECT
//     *
// FROM
//     `users`
// WHERE
//     `name` = 'foo' AND `password` = 'bar'

eloquent-dumper's People

Contributors

recca0120 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

hokhyk

eloquent-dumper's Issues

「->Sql()」變得無法使用?

您好,感謝您的套件。

我在我分別兩個專案中使用您的套件。
不過其中一個比較早開始用,是用0.2.0版。
下列的代碼是可以正常執行

$query = $this->newModelQuery();
...do something...
log_debug($query->sql());

不過這次新建的專案裝的是0.2.2版,一樣的寫法會直接拋出下列例外訊息

Call to undefined method Illuminate\Database\Eloquent\Builder::sql() 

請問使用方法有改嗎?謝謝

※不好意思標題打成->Sql()了,是->sql()才對

您好,DB中有無法支援的類型會報錯

EloquentDumperServiceProvider.php 裡面,如果預設的 db DUMPER_GRAMMAR 不是支援的類型,會造成報錯

 Argument 1 passed to Recca0120\EloquentDumper\Dumper::setPdo() must be an instance of PDO, instance of Laravel\Database\SQLAnywhere\Core\Client\SQLAnywhereClient given, called in \vendor\recca0120\eloquent-dumper\src\EloquentDumperServiceProvider.php on line 73

  at \vendor\recca0120\eloquent-dumper\src\Dumper.php:50
     46▕     /**
     47▕      * @param PDO $pdo
     48▕      * @return self
     49▕      */
  ➜  50▕     public function setPdo(PDO $pdo): self
     51▕     {
     52▕         $this->pdo = $pdo;
     53▕
     54▕         return $this;

建議增加 logger 的判斷,或是logger 放在config 做開關紀錄,感謝

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.