PDO and PostgreSQL - RAISE NOTICE

View: New views
5 Messages — Rating Filter:   Alert me  

PDO and PostgreSQL - RAISE NOTICE

by Samuel ROZE :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi !

I'm new on this mailling list, so i don't realy know if you know the
response and if it is realy here that I have to ask my question :-)

I'm working with PostgreSQL (8.3 form sources) and PDO (PHP 5.2.10 from
sources). In a Postgres function, I have a "RAISE NOTICE" command. My
function works like that in console:

=> SELECT * FROM public.test_info();
NOTICE: An information...

 test_info
------------
 ok
(1 line)

There's a NOTICE, like I want ! :-) But, when i'm using PDO, I don't
know how I can get this NOTICE, which will provide me some informations
about the usage of the function.

Code:
----------------------------------------------
<?
$sql = new PDO('...');

$stat = $sql->query('SELECT * FROM public.test_info()');
var_dump($stat);
?>
----------------------------------------------

Output:
----------------------------------------------
object(PDOStatement)#4 (1) {
  ["queryString"]=>
  string(34) "SELECT * FROM public.test_info()"
}
----------------------------------------------

Is there someone who know how I can get that ? I read some thinks about
that and pg_last_notice may returns the NOTICE, but with PDO ?

Thanks !
Samuel (French).


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: PDO and PostgreSQL - RAISE NOTICE

by Kesavan Rengarajan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
Query returns an iterable object (thanks to the comments in the php  
site) and that's why when you do a dump you just see the String,
If you just want to get one row from the resultset you can get it like  
this:
$stat = $sql->query('SELECT * FROM public.test_info()')->fetch();

More information on the PDO::query method can be found here: http://au.php.net/manual/en/pdo.query.php

Cheers
Sent from my iPhone

On 05/10/2009, at 2:06 AM, Samuel ROZE <samuel.roze@...> wrote:

> Hi !
>
> I'm new on this mailling list, so i don't realy know if you know the
> response and if it is realy here that I have to ask my question :-)
>
> I'm working with PostgreSQL (8.3 form sources) and PDO (PHP 5.2.10  
> from
> sources). In a Postgres function, I have a "RAISE NOTICE" command. My
> function works like that in console:
>
> => SELECT * FROM public.test_info();
> NOTICE: An information...
>
> test_info
> ------------
> ok
> (1 line)
>
> There's a NOTICE, like I want ! :-) But, when i'm using PDO, I don't
> know how I can get this NOTICE, which will provide me some  
> informations
> about the usage of the function.
>
> Code:
> ----------------------------------------------
> <?
> $sql = new PDO('...');
>
> $stat = $sql->query('SELECT * FROM public.test_info()');
> var_dump($stat);
> ?>
> ----------------------------------------------
>
> Output:
> ----------------------------------------------
> object(PDOStatement)#4 (1) {
>  ["queryString"]=>
>  string(34) "SELECT * FROM public.test_info()"
> }
> ----------------------------------------------
>
> Is there someone who know how I can get that ? I read some thinks  
> about
> that and pg_last_notice may returns the NOTICE, but with PDO ?
>
> Thanks !
> Samuel (French).
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: PDO and PostgreSQL - RAISE NOTICE

by Samuel ROZE :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
Thanks for your reply.

In fact, my request returns a result which i get with the fetch method.
But, it must returns other informations, which are not in the result...
This informations are neturned before the result in console...

So, i don't know how I can get that.

Samuel.

Le lundi 05 octobre 2009 à 09:55 +1100, Kesavan Rengarajan a écrit :

> Hi,
> Query returns an iterable object (thanks to the comments in the php  
> site) and that's why when you do a dump you just see the String,
> If you just want to get one row from the resultset you can get it like  
> this:
> $stat = $sql->query('SELECT * FROM public.test_info()')->fetch();
>
> More information on the PDO::query method can be found here: http://au.php.net/manual/en/pdo.query.php
>
> Cheers
> Sent from my iPhone
>
> On 05/10/2009, at 2:06 AM, Samuel ROZE <samuel.roze@...> wrote:
>
> > Hi !
> >
> > I'm new on this mailling list, so i don't realy know if you know the
> > response and if it is realy here that I have to ask my question :-)
> >
> > I'm working with PostgreSQL (8.3 form sources) and PDO (PHP 5.2.10  
> > from
> > sources). In a Postgres function, I have a "RAISE NOTICE" command. My
> > function works like that in console:
> >
> > => SELECT * FROM public.test_info();
> > NOTICE: An information...
> >
> > test_info
> > ------------
> > ok
> > (1 line)
> >
> > There's a NOTICE, like I want ! :-) But, when i'm using PDO, I don't
> > know how I can get this NOTICE, which will provide me some  
> > informations
> > about the usage of the function.
> >
> > Code:
> > ----------------------------------------------
> > <?
> > $sql = new PDO('...');
> >
> > $stat = $sql->query('SELECT * FROM public.test_info()');
> > var_dump($stat);
> > ?>
> > ----------------------------------------------
> >
> > Output:
> > ----------------------------------------------
> > object(PDOStatement)#4 (1) {
> >  ["queryString"]=>
> >  string(34) "SELECT * FROM public.test_info()"
> > }
> > ----------------------------------------------
> >
> > Is there someone who know how I can get that ? I read some thinks  
> > about
> > that and pg_last_notice may returns the NOTICE, but with PDO ?
> >
> > Thanks !
> > Samuel (French).
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: PDO and PostgreSQL - RAISE NOTICE

by Lester Caine :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Samuel ROZE wrote:
> Hi,
> Thanks for your reply.
>
> In fact, my request returns a result which i get with the fetch method.
> But, it must returns other informations, which are not in the result...
> This informations are neturned before the result in console...
>
> So, i don't know how I can get that.

PDO does not support many of the 'additional' features that databases
provide. It's designed to provide a 'lowest common denominator' solution
JUST for the data. If you are NOT planning to use any other database
then you may well find that the native postgres driver will provide
these additional facilities.

I use Firebird myself so can't comment on the 'fine detail' on postgres,
but some of the Firebird options can't easily be supported in PDO ;)

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: PDO and PostgreSQL - RAISE NOTICE

by Samuel ROZE :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks a lot ! I'm now understanding why PDO exists.. It is not for
replace the actual PostgreSQL/MySQL/SQLite/Firebird/... PHP drivers but
for help to developp with many DB with one code.

Well... I can developp an extension to PDO PostgreSQL driver, is that
correct ? It may help many users like me... :-)

Thanks Lester !
Samuel.

Le lundi 05 octobre 2009 à 08:36 +0100, Lester Caine a écrit :

> Samuel ROZE wrote:
> > Hi,
> > Thanks for your reply.
> >
> > In fact, my request returns a result which i get with the fetch method.
> > But, it must returns other informations, which are not in the result...
> > This informations are neturned before the result in console...
> >
> > So, i don't know how I can get that.
>
> PDO does not support many of the 'additional' features that databases
> provide. It's designed to provide a 'lowest common denominator' solution
> JUST for the data. If you are NOT planning to use any other database
> then you may well find that the native postgres driver will provide
> these additional facilities.
>
> I use Firebird myself so can't comment on the 'fine detail' on postgres,
> but some of the Firebird options can't easily be supported in PDO ;)
>
> --
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
>


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php