Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query params substitution #21

Closed
JonoB opened this issue Oct 18, 2013 · 10 comments
Closed

Query params substitution #21

JonoB opened this issue Oct 18, 2013 · 10 comments

Comments

@JonoB
Copy link

JonoB commented Oct 18, 2013

It would be great if this could automatically substitute the params for each query into the query string

@barryvdh
Copy link
Owner

So select * fromuserswhereid= ? limit 1 would be select * fromuserswhereid= 4 limit 1? Would probably be nice, but should be in the php-debugbar project, because I use the default PdoDataCollector

@barryvdh
Copy link
Owner

Actually, there already is an option to substitue the parameters in a TracedStatement, I'll check why that isn't used.

@JonoB
Copy link
Author

JonoB commented Oct 25, 2013

Looks like this has been enabled now php-debugbar/php-debugbar@f5cb5a1

Wasn't sure if you wanted to expose this config value in the laravel version, but something like this would probably work (untested):

if($this->collects('db', true) and isset($this->app['db'])){
    try{
        $pdo = new TraceablePDO( $this->app['db']->getPdo());
        $collector = new PDOCollector($pdo);
        $collector->setRenderSqlWithParams($this->app['config']->get('laravel-debugbar::config.render_sql_with_params', true));
        $debugbar->addCollector($collector);
    }catch(\PDOException $e){
        //Not connection set..
    }
}

@barryvdh
Copy link
Owner

Yeah I'll make a config for this.
Op 25 okt. 2013 11:13 schreef "JonoB" notifications@github.com:

Looks like this has been enabled now php-debugbar/php-debugbar@f5cb5a1php-debugbar/php-debugbar@f5cb5a1

Wasn't sure if you wanted to expose this config value in the laravel
version, but something like this would probably work (untested):

if($this->collects('db', true) and isset($this->app['db'])){
try{
$pdo = new TraceablePDO( $this->app['db']->getPdo());
$collector = new PDOCollector($pdo);
$collector->setRenderSqlWithParams($this->app['config']->get('laravel-debugbar::config.render_sql_with_params', true));
$debugbar->addCollector($collector);
}catch(\PDOException $e){
//Not connection set..
}}


Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-27075916
.

@barryvdh
Copy link
Owner

Added a config for this, probably need to re-publish your config, but it's on by default.

@JonoB
Copy link
Author

JonoB commented Oct 26, 2013

Awesome, thanks

@JonoB
Copy link
Author

JonoB commented Nov 4, 2013

Hey Barry, just tried this out for the first time. Is there a reason that the params are surrounded with < and >?

select * from `users` where `id` = <26313> limit 1

I'm guessing that this is a phpdebugbar issue?

@barryvdh
Copy link
Owner

barryvdh commented Nov 4, 2013

Yeah I said that here: php-debugbar/php-debugbar#38
That is the behaviour of the function that was already present.
Maybe you can submit a PR to change that to '123' instead of <123>

@barryvdh
Copy link
Owner

barryvdh commented Nov 4, 2013

Default is now ', but it is an option in the latest version.

@JonoB
Copy link
Author

JonoB commented Nov 4, 2013

Awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants