\Zend\Db and what to do?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

\Zend\Db and what to do?

Marc Tempelmeier
Hi,

I wrote a new DB Platform for our informix Db. And now I play aroung with Apigility to build a few Services.
The DbSelect Paginator throws me an error, no surprise there, because Informix has no limit... ok, it has but not like other db:

SELECT SKIP 25 FIRST 25 web_project.* FROM web_project

Which classes I have to write to bring full Informix Support to ZF2?

Thank you very much for tossing me in the right direction.

Love

Marc
(G0re on IRC)
Reply | Threaded
Open this post in threaded view
|

Re: \Zend\Db and what to do?

Ralf Eggert
Hi Marc,

first of all, I have no idea about informix at all. But this is what I
would do to start informix support for ZF2.

First, you need the driver. You must decide if you want to use PDO or
the native ifx extension. If you want to use PDO the driver part is
quite simple, because you can use the Zend\Db\Adapter\Driver\Pdo. If not
you need to implement the native ifx support. Please look at the classes
of Zend\Db\Adapter\Driver\Mysqli to get you started.

Second, you need the platform. For example look at the MySQL
implementation at Zend\Db\Adapter\Platform\Mysql. The platform is
independent from the driver, ie. from PDO or ifx support.

Third, you need the SQL implementation. Please look at the classes of
Zend\Db\Sql\Platform\Mysql for MySQL inspiration. The concrete
implementation for LIMIT and OFFSET can be found in the class
Zend\Db\Sql\Platform\Mysql\SelectDecorator.

Please could others correct me, if I am wrong in any point?

Marc, good luck and have fun. Although I won't need it personally, but
it would be nice if you could add your implementation to the framework
by a PR if finished or at least create a module for the informix support.

Thanks and best regards,

Ralf

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

AW: [fw-general] \Zend\Db and what to do?

Marc Tempelmeier
Hi,

thank you, I have already the adapter platform and got the limit and skip on the sql platform working.

But a few questions remain, in \Zend\Db\Sql\Select in processSelect the quantifier are processed.
The skip and first of informix seem similar and my first apporach was to add another select specification with 4 arguments and
do something like this:

    protected $specifications = array(
        ...
        self::SELECT => array(
            'SELECT %1$s FROM %2$s' => array(
                array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '),
                null
            ),
            'SELECT %1$s %2$s FROM %3$s' => array(
                null,
                array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '),
                null
            ),
            'SELECT SKIP %1$s FIRST %2$s %3$s FROM %4$s' => array(
                null,
                null,
                array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '),
                null
            ),
            'SELECT %1$s' => array(
                array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '),
            ),
        ),
       ...

in processSelect() I return:
        if (!isset($table)) {
            return array($columns);
        } elseif (isset($quantifier)) {
            return array($quantifier, $columns, $table);
        } elseif (isset($this->offset) && isset($this->limit)) {
            return array($this->offset, $this->limit, $columns, $table);
        } else {
            return array($columns, $table);
        }

That worked likea charm, but is a totally other way than in Platform\MySql.
Is there an oversight on my side why the other method is better in Mysql?

Greetings

Marc


 

> -----Ursprüngliche Nachricht-----
> Von: Ralf Eggert [mailto:[hidden email]]
> Gesendet: Mittwoch, 26. November 2014 17:43
> An: [hidden email]
> Betreff: Re: [fw-general] \Zend\Db and what to do?
>
> Hi Marc,
>
> first of all, I have no idea about informix at all. But this is what I would do to
> start informix support for ZF2.
>
> First, you need the driver. You must decide if you want to use PDO or the
> native ifx extension. If you want to use PDO the driver part is quite simple,
> because you can use the Zend\Db\Adapter\Driver\Pdo. If not you need to
> implement the native ifx support. Please look at the classes of
> Zend\Db\Adapter\Driver\Mysqli to get you started.
>
> Second, you need the platform. For example look at the MySQL
> implementation at Zend\Db\Adapter\Platform\Mysql. The platform is
> independent from the driver, ie. from PDO or ifx support.
>
> Third, you need the SQL implementation. Please look at the classes of
> Zend\Db\Sql\Platform\Mysql for MySQL inspiration. The concrete
> implementation for LIMIT and OFFSET can be found in the class
> Zend\Db\Sql\Platform\Mysql\SelectDecorator.
>
> Please could others correct me, if I am wrong in any point?
>
> Marc, good luck and have fun. Although I won't need it personally, but it
> would be nice if you could add your implementation to the framework by a
> PR if finished or at least create a module for the informix support.
>
> Thanks and best regards,
>
> Ralf
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>

Reply | Threaded
Open this post in threaded view
|

AW: [fw-general] \Zend\Db and what to do?

Marc Tempelmeier
Hi again,

I just saw that in Mysql it´s just appended to the end, so the
processLimitOffset() in Zend\Db\Sql\Platform\IbmDb2\SelectDecorator is a better example.

There it seems some manipulation happens, but I don´t know why it´s done that way.

Greetings

Marc

> -----Ursprüngliche Nachricht-----
> Von: Marc Tempelmeier [mailto:[hidden email]]
> Gesendet: Donnerstag, 27. November 2014 10:37
> An: [hidden email]
> Betreff: AW: [fw-general] \Zend\Db and what to do?
>
> Hi,
>
> thank you, I have already the adapter platform and got the limit and skip on
> the sql platform working.
>
> But a few questions remain, in \Zend\Db\Sql\Select in processSelect the
> quantifier are processed.
> The skip and first of informix seem similar and my first apporach was to add
> another select specification with 4 arguments and do something like this:
>
>     protected $specifications = array(
>         ...
>         self::SELECT => array(
>             'SELECT %1$s FROM %2$s' => array(
>                 array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '),
>                 null
>             ),
>             'SELECT %1$s %2$s FROM %3$s' => array(
>                 null,
>                 array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '),
>                 null
>             ),
>             'SELECT SKIP %1$s FIRST %2$s %3$s FROM %4$s' => array(
>                 null,
>                 null,
>                 array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '),
>                 null
>             ),
>             'SELECT %1$s' => array(
>                 array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '),
>             ),
>         ),
>        ...
>
> in processSelect() I return:
>         if (!isset($table)) {
>             return array($columns);
>         } elseif (isset($quantifier)) {
>             return array($quantifier, $columns, $table);
>         } elseif (isset($this->offset) && isset($this->limit)) {
>             return array($this->offset, $this->limit, $columns, $table);
>         } else {
>             return array($columns, $table);
>         }
>
> That worked likea charm, but is a totally other way than in Platform\MySql.
> Is there an oversight on my side why the other method is better in Mysql?
>
> Greetings
>
> Marc
>
>
>
>
> > -----Ursprüngliche Nachricht-----
> > Von: Ralf Eggert [mailto:[hidden email]]
> > Gesendet: Mittwoch, 26. November 2014 17:43
> > An: [hidden email]
> > Betreff: Re: [fw-general] \Zend\Db and what to do?
> >
> > Hi Marc,
> >
> > first of all, I have no idea about informix at all. But this is what I
> > would do to start informix support for ZF2.
> >
> > First, you need the driver. You must decide if you want to use PDO or
> > the native ifx extension. If you want to use PDO the driver part is
> > quite simple, because you can use the Zend\Db\Adapter\Driver\Pdo. If
> > not you need to implement the native ifx support. Please look at the
> > classes of Zend\Db\Adapter\Driver\Mysqli to get you started.
> >
> > Second, you need the platform. For example look at the MySQL
> > implementation at Zend\Db\Adapter\Platform\Mysql. The platform is
> > independent from the driver, ie. from PDO or ifx support.
> >
> > Third, you need the SQL implementation. Please look at the classes of
> > Zend\Db\Sql\Platform\Mysql for MySQL inspiration. The concrete
> > implementation for LIMIT and OFFSET can be found in the class
> > Zend\Db\Sql\Platform\Mysql\SelectDecorator.
> >
> > Please could others correct me, if I am wrong in any point?
> >
> > Marc, good luck and have fun. Although I won't need it personally, but
> > it would be nice if you could add your implementation to the framework
> > by a PR if finished or at least create a module for the informix support.
> >
> > Thanks and best regards,
> >
> > Ralf
> >
> > --
> > List: [hidden email]
> > Info: http://framework.zend.com/archives
> > Unsubscribe: [hidden email]
> >