Inserting multiple element

6 messages Options
Embed this post
Permalink
Mathieu Suen-3

Inserting multiple element

Reply Threaded More More options
Print post
Permalink
Hi,

Is there a way to insert several row at the same time with the adapter?

The expect query would look like:

INSERT (num) VALUES (2), (3), (6);

Thanks

--
-- Mathieu Suen
--
Nicolas GREVET

Re: Inserting multiple element

Reply Threaded More More options
Print post
Permalink
See: http://framework.zend.com/issues/browse/ZF-2322
It would be a VERY nice feature, especially if it supported bulk update too.
Unfortunately, this is opened since 17/Dec/07 and doesn't seem to be
moving soon.
You could still use this method instead :
http://www.mail-archive.com/fw-general@.../msg12741.html

Regards,
-- Nicolas


Mathieu Suen a écrit :

> Hi,
>
> Is there a way to insert several row at the same time with the adapter?
>
> The expect query would look like:
>
> INSERT (num) VALUES (2), (3), (6);
>
> Thanks
>
umpirsky

Re: Inserting multiple element

Reply Threaded More More options
Print post
Permalink
The reason why this is not implemented is that not all RDBMS support bulk insert. But I vote for implementing it for ones that support it and maybe emulate for others or throw unsupported operation exception in that case. It would be nice to have this for at least MySQL.

Regards,
Saša Stamenković


On Tue, Oct 20, 2009 at 10:53 AM, Nicolas GREVET <[hidden email]> wrote:
See: http://framework.zend.com/issues/browse/ZF-2322
It would be a VERY nice feature, especially if it supported bulk update too.
Unfortunately, this is opened since 17/Dec/07 and doesn't seem to be moving soon.
You could still use this method instead :
http://www.mail-archive.com/fw-general@.../msg12741.html

Regards,
-- Nicolas


Mathieu Suen a écrit :

Hi,

Is there a way to insert several row at the same time with the adapter?

The expect query would look like:

INSERT (num) VALUES (2), (3), (6);

Thanks


umpirsky

Re: Inserting multiple element

Reply Threaded More More options
Print post
Permalink
Also, please vote for http://framework.zend.com/issues/browse/ZF-2322

Regards,
Saša Stamenković


On Tue, Oct 20, 2009 at 11:12 AM, Саша Стаменковић <[hidden email]> wrote:
The reason why this is not implemented is that not all RDBMS support bulk insert. But I vote for implementing it for ones that support it and maybe emulate for others or throw unsupported operation exception in that case. It would be nice to have this for at least MySQL.

Regards,
Saša Stamenković



On Tue, Oct 20, 2009 at 10:53 AM, Nicolas GREVET <[hidden email]> wrote:
See: http://framework.zend.com/issues/browse/ZF-2322
It would be a VERY nice feature, especially if it supported bulk update too.
Unfortunately, this is opened since 17/Dec/07 and doesn't seem to be moving soon.
You could still use this method instead :
http://www.mail-archive.com/fw-general@.../msg12741.html

Regards,
-- Nicolas


Mathieu Suen a écrit :

Hi,

Is there a way to insert several row at the same time with the adapter?

The expect query would look like:

INSERT (num) VALUES (2), (3), (6);

Thanks



Hector Virgen

Re: Inserting multiple element

Reply Threaded More More options
Print post
Permalink
I have written a patch for the Pdo_Mysql adapter that adds two methods:

// Inserts multiple rows into a table using one query
int Zend_Db_Adapter_Pdo_Mysql::insertMultiple(string $table, array $rows);

// Inserts multiple rows using ON DUPLICATE KEY UPDATE syntax
int Zend_Db_Adapter_Pdo_Mysql::insertOrUpdateMultiple(string $table, array $insertData, array $updateData = null);

I currently don't have a signed CLA so I need to get that before I can submit the patch. In the mean time, I'll submit the patch to the issue tracker for review.

--
Hector


On Tue, Oct 20, 2009 at 2:14 AM, Саша Стаменковић <[hidden email]> wrote:
Also, please vote for http://framework.zend.com/issues/browse/ZF-2322

Regards,
Saša Stamenković



On Tue, Oct 20, 2009 at 11:12 AM, Саша Стаменковић <[hidden email]> wrote:
The reason why this is not implemented is that not all RDBMS support bulk insert. But I vote for implementing it for ones that support it and maybe emulate for others or throw unsupported operation exception in that case. It would be nice to have this for at least MySQL.

Regards,
Saša Stamenković



On Tue, Oct 20, 2009 at 10:53 AM, Nicolas GREVET <[hidden email]> wrote:
See: http://framework.zend.com/issues/browse/ZF-2322
It would be a VERY nice feature, especially if it supported bulk update too.
Unfortunately, this is opened since 17/Dec/07 and doesn't seem to be moving soon.
You could still use this method instead :
http://www.mail-archive.com/fw-general@.../msg12741.html

Regards,
-- Nicolas


Mathieu Suen a écrit :

Hi,

Is there a way to insert several row at the same time with the adapter?

The expect query would look like:

INSERT (num) VALUES (2), (3), (6);

Thanks




umpirsky

Re: Inserting multiple element

Reply Threaded More More options
Print post
Permalink
Very nice!

Regards,
Saša Stamenković


On Tue, Oct 20, 2009 at 7:20 PM, Hector Virgen <[hidden email]> wrote:
I have written a patch for the Pdo_Mysql adapter that adds two methods:

// Inserts multiple rows into a table using one query
int Zend_Db_Adapter_Pdo_Mysql::insertMultiple(string $table, array $rows);

// Inserts multiple rows using ON DUPLICATE KEY UPDATE syntax
int Zend_Db_Adapter_Pdo_Mysql::insertOrUpdateMultiple(string $table, array $insertData, array $updateData = null);

I currently don't have a signed CLA so I need to get that before I can submit the patch. In the mean time, I'll submit the patch to the issue tracker for review.

--
Hector



On Tue, Oct 20, 2009 at 2:14 AM, Саша Стаменковић <[hidden email]> wrote:
Also, please vote for http://framework.zend.com/issues/browse/ZF-2322

Regards,
Saša Stamenković



On Tue, Oct 20, 2009 at 11:12 AM, Саша Стаменковић <[hidden email]> wrote:
The reason why this is not implemented is that not all RDBMS support bulk insert. But I vote for implementing it for ones that support it and maybe emulate for others or throw unsupported operation exception in that case. It would be nice to have this for at least MySQL.

Regards,
Saša Stamenković



On Tue, Oct 20, 2009 at 10:53 AM, Nicolas GREVET <[hidden email]> wrote:
See: http://framework.zend.com/issues/browse/ZF-2322
It would be a VERY nice feature, especially if it supported bulk update too.
Unfortunately, this is opened since 17/Dec/07 and doesn't seem to be moving soon.
You could still use this method instead :
http://www.mail-archive.com/fw-general@.../msg12741.html

Regards,
-- Nicolas


Mathieu Suen a écrit :

Hi,

Is there a way to insert several row at the same time with the adapter?

The expect query would look like:

INSERT (num) VALUES (2), (3), (6);

Thanks