Print a SQL statement that ORM executes.

30 views
Skip to first unread message

Seshu Kumar

unread,
Jan 5, 2010, 6:40:55 AM1/5/10
to Outlet ORM
Can we have a fix to the ORM that can print or debug the SQL
statements the Outlet executes ?

pihentagy

unread,
Jan 6, 2010, 12:20:39 PM1/6/10
to Outlet ORM
In OutletMapper.php insert 2 lines before the $stmt->execute(theargs):
(replace theargs to the actual args)

var_dump($stmt->queryString);
var_dump(theargs);

until an official solution arrives from the devs.

Jonathan Leibiusky

unread,
Jan 6, 2010, 4:08:04 PM1/6/10
to outle...@googlegroups.com
Yes, It seems like an excellent idea. Really good for debugging purposes.
I think we can definitely include some kind of solution in outlet. I'll work on that. It'll take a bit longer than usual since everyone is on holidays :)

--
You received this message because you are subscribed to the Google Groups "Outlet ORM" group.
To post to this group, send email to outle...@googlegroups.com.
To unsubscribe from this group, send email to outlet-orm+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/outlet-orm?hl=en.




Alvaro Carrasco

unread,
Jan 6, 2010, 5:48:33 PM1/6/10
to outle...@googlegroups.com
Here is a way to do it right now without changing the outlet code.
Since release 1.0rc1 outlet can take a PDO instance instead of the dsn
string (i know, i really need to add this to the manual). So you can
create a class that extends PDO and that logs your queries and pass it
to the config:
<?
class DebugPDO {
function prepare ($sql) {
echo $sql;
return parent::prepare($sql);
}
... etc
}
?>

<?php
return array(
'connection' => array(
'pdo' => new DebugPDO('mysql:host=localhost;dbname=test', 'user', 'pass'),
'dialect' => 'mysql'
)
'classes' => ...
);
?>

It's less work than it seems.

Eventually we should provide a version of that DebugPDO class in the
package. Something similar to propel:
http://propel.phpdb.org/trac/wiki/Users/Documentation/1.3/DebugPDO
http://propel.phpdb.org/trac/browser/branches/1.3/runtime/classes/propel/util/DebugPDO.php

Alvaro

Alvaro Carrasco

unread,
Jan 6, 2010, 5:50:12 PM1/6/10
to outle...@googlegroups.com
Sorry, i made a mistake on the class definition:

class DebugPDO {

should be:

class DebugPDO extends PDO {

Alvaro

ArtVolk

unread,
Jan 9, 2010, 5:43:33 AM1/9/10
to Outlet ORM
Thanks!

I've created a class from Propel version, hope this can help somebody
(sorry, the post is in Russian, but the code is in PHP :))

http://snippets.crisp-studio.com/view/66/otladka-i-statistika-zaprosov-v-php-pdo

On 7 янв, 00:50, Alvaro Carrasco <simple...@gmail.com> wrote:
> Sorry, i made a mistake on the class definition:
>
>   class DebugPDO {
>
> should be:
>
>   class DebugPDO extends PDO {
>
> Alvaro
>

> >http://propel.phpdb.org/trac/browser/branches/1.3/runtime/classes/pro...
>
> > Alvaro


>
> > On Wed, Jan 6, 2010 at 2:08 PM, Jonathan Leibiusky <ionat...@gmail.com> wrote:
> >> Yes, It seems like an excellent idea. Really good for debugging purposes.
> >> I think we can definitely include some kind of solution in outlet. I'll work
> >> on that. It'll take a bit longer than usual since everyone is on holidays :)
>

Fabio R.

unread,
Jan 21, 2010, 2:07:48 PM1/21/10
to outle...@googlegroups.com
What if Outlet collected all executed statements and let the user decide what to do? (print or log)
Maybe we could add a getExecutedStatements() method to outlet instance that returns an array of all SQL statements.


--
Fábio Rehm

ArtVolk

unread,
Jan 22, 2010, 5:29:05 AM1/22/10
to Outlet ORM
It will be nice, but using first approach we are able to measure
execution time, print query parameters etc...

I think it will be a lot of work to integrate all these to Outlet
itself. Not sure it needs all this stuff.

On 21 янв, 21:07, "Fabio R." <fgr...@gmail.com> wrote:
> What if Outlet collected all executed statements and let the user decide
> what to do? (print or log)
> Maybe we could add a getExecutedStatements() method to outlet instance that
> returns an array of all SQL statements.
>
> --
> Fábio Rehm
>

> On Sat, Jan 9, 2010 at 7:43 AM, ArtVolk <artv...@gmail.com> wrote:
> > Thanks!
>
> > I've created a class from Propel version, hope this can help somebody
> > (sorry, the post is in Russian, but the code is in PHP :))
>

> >http://snippets.crisp-studio.com/view/66/otladka-i-statistika-zaproso...

> > > >>> outlet-orm+...@googlegroups.com<outlet-orm%2Bunsu...@googlegroups.com>


> > .
> > > >>> For more options, visit this group at
> > > >>>http://groups.google.com/group/outlet-orm?hl=en.
>
> > > >> --
> > > >> You received this message because you are subscribed to the Google
> > Groups
> > > >> "Outlet ORM" group.
> > > >> To post to this group, send email to outle...@googlegroups.com.
> > > >> To unsubscribe from this group, send email to

> > > >> outlet-orm+...@googlegroups.com<outlet-orm%2Bunsu...@googlegroups.com>


> > .
> > > >> For more options, visit this group at
> > > >>http://groups.google.com/group/outlet-orm?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Outlet ORM" group.
> > To post to this group, send email to outle...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > outlet-orm+...@googlegroups.com<outlet-orm%2Bunsu...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages