librelist archives

« back to archive

PDO for all the SQL databases?

PDO for all the SQL databases?

From:
Loic d'Anterroches
Date:
2012-07-30 @ 12:32
Hello,

I propose to use PDO for all the SQL databases. That is, when you will
request a DB object from Photon, you will get a PDO connection to a
given database. It is then up to you to do what you want with it.

Fine?

loïc

Re: [photon.users] PDO for all the SQL databases?

From:
William Martin
Date:
2012-07-30 @ 12:42
Loic,

Ok for me, i don't use SQL anymore ;)

William

On Mon, Jul 30, 2012 at 2:32 PM, Loic d'Anterroches <loic@ceondo.com> wrote:
> Hello,
>
> I propose to use PDO for all the SQL databases. That is, when you will
> request a DB object from Photon, you will get a PDO connection to a
> given database. It is then up to you to do what you want with it.
>
> Fine?
>
> loïc



-- 
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com

Re: [photon.users] PDO for all the SQL databases?

From:
Loic d'Anterroches
Date:
2012-07-30 @ 12:44

On 2012-07-30 14:42, William MARTIN wrote:
> Loic,
> 
> Ok for me, i don't use SQL anymore ;)

:D

ok, so, I am going to update for SQLite as it is not using PDO at the
moment. I like PDO because it gives me the feeling of the Python and
Perl DB API.

loïc

> On Mon, Jul 30, 2012 at 2:32 PM, Loic d'Anterroches <loic@ceondo.com> wrote:
>> Hello,
>>
>> I propose to use PDO for all the SQL databases. That is, when you will
>> request a DB object from Photon, you will get a PDO connection to a
>> given database. It is then up to you to do what you want with it.
>>
>> Fine?
>>
>> loïc
> 
> 
> 

-- 
Dr Loïc d'Anterroches
Founder Céondo Ltd

w: www.ceondo.com       |  e: loic@ceondo.com
t: +44 (0)207 183 0016  |  f: +44 (0)207 183 0124

Céondo Ltd
Dalton House
60 Windsor Avenue
London
SW19 2RR / United Kingdom

Re: [photon.users] PDO for all the SQL databases?

From:
Loic d'Anterroches
Date:
2012-08-01 @ 19:05
Ok, PDO for PostgreSQL landed in, a simple usage:

        $db = DB::get('default');
        $sql = 'SELECT * FROM happycoders';
        $out = 'Output:' . "\n";
        foreach ($db->query($sql) as $row) {
            $out .= $row['email'] . "\t" .
                $row['login'] . "\t" . $row['first_name'] . "\t" .
                $row['last_name'] . "\n";
        }
        return new Response($out, 'text/tab-separated-values');

Pretty simple to use, you could even "compact" by doing:

    DB::get()->query($sql) as $row

In your config.php just put:

           'databases' =>
           array('default' =>
                 array('engine' => '\photon\db\PostgreSQL',
                       'database' => 'yourdatabase',
                       'user' => 'theuser',
                       'password' => 'P4SSW0RD',
                       'server' => 'IP or localhost',
                       ),
                 ),

the server and database "key" are renamed as host and dbname for
PostgreSQL DSN using PDO, you can see the list of all the "keys" you can
put here:

http://www.php.net/manual/en/ref.pdo-pgsql.connection.php

user and password are automatically taken out of the DSN and used in the
specific arguments when creating the PDO connection.

the extra keys are used to populate the options. You could add something
like:

PDO::ATTR_PERSISTENT => true

and this would go as option. Basically you get the full PDO without
limitations.

loïc


On 2012-07-30 14:44, Loic d'Anterroches wrote:
> 
> 
> On 2012-07-30 14:42, William MARTIN wrote:
>> Loic,
>>
>> Ok for me, i don't use SQL anymore ;)
> 
> :D
> 
> ok, so, I am going to update for SQLite as it is not using PDO at the
> moment. I like PDO because it gives me the feeling of the Python and
> Perl DB API.
> 
> loïc
> 
>> On Mon, Jul 30, 2012 at 2:32 PM, Loic d'Anterroches <loic@ceondo.com> wrote:
>>> Hello,
>>>
>>> I propose to use PDO for all the SQL databases. That is, when you will
>>> request a DB object from Photon, you will get a PDO connection to a
>>> given database. It is then up to you to do what you want with it.
>>>
>>> Fine?
>>>
>>> loïc
>>
>>
>>
> 

Re: [photon.users] PDO for all the SQL databases?

From:
William Martin
Date:
2012-08-02 @ 06:10
Thanks

On Wed, Aug 1, 2012 at 9:05 PM, Loic d'Anterroches <loic@ceondo.com> wrote:
> Ok, PDO for PostgreSQL landed in, a simple usage:
>
>         $db = DB::get('default');
>         $sql = 'SELECT * FROM happycoders';
>         $out = 'Output:' . "\n";
>         foreach ($db->query($sql) as $row) {
>             $out .= $row['email'] . "\t" .
>                 $row['login'] . "\t" . $row['first_name'] . "\t" .
>                 $row['last_name'] . "\n";
>         }
>         return new Response($out, 'text/tab-separated-values');
>
> Pretty simple to use, you could even "compact" by doing:
>
>     DB::get()->query($sql) as $row
>
> In your config.php just put:
>
>            'databases' =>
>            array('default' =>
>                  array('engine' => '\photon\db\PostgreSQL',
>                        'database' => 'yourdatabase',
>                        'user' => 'theuser',
>                        'password' => 'P4SSW0RD',
>                        'server' => 'IP or localhost',
>                        ),
>                  ),
>
> the server and database "key" are renamed as host and dbname for
> PostgreSQL DSN using PDO, you can see the list of all the "keys" you can
> put here:
>
> http://www.php.net/manual/en/ref.pdo-pgsql.connection.php
>
> user and password are automatically taken out of the DSN and used in the
> specific arguments when creating the PDO connection.
>
> the extra keys are used to populate the options. You could add something
> like:
>
> PDO::ATTR_PERSISTENT => true
>
> and this would go as option. Basically you get the full PDO without
> limitations.
>
> loïc
>
>
> On 2012-07-30 14:44, Loic d'Anterroches wrote:
>>
>>
>> On 2012-07-30 14:42, William MARTIN wrote:
>>> Loic,
>>>
>>> Ok for me, i don't use SQL anymore ;)
>>
>> :D
>>
>> ok, so, I am going to update for SQLite as it is not using PDO at the
>> moment. I like PDO because it gives me the feeling of the Python and
>> Perl DB API.
>>
>> loïc
>>
>>> On Mon, Jul 30, 2012 at 2:32 PM, Loic d'Anterroches <loic@ceondo.com> wrote:
>>>> Hello,
>>>>
>>>> I propose to use PDO for all the SQL databases. That is, when you will
>>>> request a DB object from Photon, you will get a PDO connection to a
>>>> given database. It is then up to you to do what you want with it.
>>>>
>>>> Fine?
>>>>
>>>> loïc
>>>
>>>
>>>
>>



-- 
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com