Support IGNORE clause for INSERT
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
Aerendir <adamo.cre... @gmail.com>
Date: Sat, 21 Jul 2012 11:37:59 -0700 (PDT)
Local: Sat, Jul 21 2012 2:37 pm
Subject: Support IGNORE clause for INSERT
Hi at all, this is my first post on this group, so excuse me for any error of any kind :)
I'm developing an app using Joomla! Platform 12.1 and i need to use IGNORE clause for a set of multiple insert.
Actually, the framework doesn't support the use of this clause, but, reading the code, it seems quite simple to add it.
If i'm not wrong it could be sufficient to edit the method insert of the JDatabaseQuery class (joomla/database/query.php).
Now the function is this:
*public function **insert*($table, $incrementField*=**false*) { $this*->*type *=* 'insert'; $this*->*insert *= new *JDatabaseQueryElement('INSERT INTO', $table); $this*->*autoIncrementField *= *$incrementField;
*return *$this;
}
I think (but i could be wrong! I don't yet fully know the logic of the
entire database package) that the function could be rewrote in this way:
*public function **insert*($table, $incrementField*=**false*, $ignore=*false *) { $this*->*type *=* 'insert';
*if*($ignore) { $this*->*insert *= new *JDatabaseQueryElement('INSERT IGNORE INTO', $table);
}
*else
*{
$this*->*insert *= new *JDatabaseQueryElement('INSERT INTO', $table);
}
$this*->*autoIncrementField *= *$incrementField;
*return *$this;
}
What do you think about?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Michael Babker <mbab... @flbab.com>
Date: Sat, 21 Jul 2012 13:50:44 -0500
Local: Sat, Jul 21 2012 2:50 pm
Subject: Re: [jplatform] Support IGNORE clause for INSERT
INSERT IGNORE INTO is MySQL specific syntax. I know it isn't supported by PostgreSQL, not sure about others. Could it be added, sure, but it would probably need to be in JDatabaseQueryMysqli if it isn't supported in other drivers.
-Michael
Please pardon any errors, this message was sent from my iPhone.
On Jul 21, 2012, at 1:37 PM, Aerendir <adamo.cre... @gmail.com> wrote:
> Hi at all,
> this is my first post on this group, so excuse me for any error of any kind :)
> I'm developing an app using Joomla! Platform 12.1 and i need to use IGNORE clause for a set of multiple insert.
> Actually, the framework doesn't support the use of this clause, but, reading the code, it seems quite simple to add it.
> If i'm not wrong it could be sufficient to edit the method insert of the JDatabaseQuery class (joomla/database/query.php).
> Now the function is this:
> public function insert($table, $incrementField=false)
> {
> $this->type = 'insert';
> $this->insert = new JDatabaseQueryElement('INSERT INTO', $table);
> $this->autoIncrementField = $incrementField;
> return $this;
> }
> I think (but i could be wrong! I don't yet fully know the logic of the entire database package) that the function could be rewrote in this way:
> public function insert($table, $incrementField=false, $ignore=false)
> {
> $this->type = 'insert';
> if($ignore)
> {
> $this->insert = new JDatabaseQueryElement('INSERT IGNORE INTO', $table);
> }
> else
> {
> $this->insert = new JDatabaseQueryElement('INSERT INTO', $table);
> }
> $this->autoIncrementField = $incrementField;
> return $this;
> }
> What do you think about?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Sam Moffatt <pasa... @gmail.com>
Date: Sat, 21 Jul 2012 12:19:38 -0700
Local: Sat, Jul 21 2012 3:19 pm
Subject: Re: [jplatform] Support IGNORE clause for INSERT
Yes, INSERT IGNORE is a MySQL specific extension and should be avoided
if portability is a concern.
Cheers,
Sam Moffatt
http://pasamio.id.au
On Sat, Jul 21, 2012 at 11:50 AM, Michael Babker <mbab
... @flbab.com> wrote:
> INSERT IGNORE INTO is MySQL specific syntax. I know it isn't supported by
> PostgreSQL, not sure about others. Could it be added, sure, but it would
> probably need to be in JDatabaseQueryMysqli if it isn't supported in other
> drivers.
> -Michael
> Please pardon any errors, this message was sent from my iPhone.
> On Jul 21, 2012, at 1:37 PM, Aerendir <adamo.cre... @gmail.com> wrote:
> Hi at all,
> this is my first post on this group, so excuse me for any error of any kind
> :)
> I'm developing an app using Joomla! Platform 12.1 and i need to use IGNORE
> clause for a set of multiple insert.
> Actually, the framework doesn't support the use of this clause, but, reading
> the code, it seems quite simple to add it.
> If i'm not wrong it could be sufficient to edit the method insert of the
> JDatabaseQuery class (joomla/database/query.php).
> Now the function is this:
> public function insert($table, $incrementField=false)
> {
> $this->type = 'insert';
> $this->insert = new JDatabaseQueryElement('INSERT INTO', $table);
> $this->autoIncrementField = $incrementField;
> return $this;
> }
> I think (but i could be wrong! I don't yet fully know the logic of the
> entire database package) that the function could be rewrote in this way:
> public function insert($table, $incrementField=false, $ignore=false)
> {
> $this->type = 'insert';
> if($ignore)
> {
> $this->insert = new JDatabaseQueryElement('INSERT IGNORE INTO', $table);
> }
> else
> {
> $this->insert = new JDatabaseQueryElement('INSERT INTO', $table);
> }
> $this->autoIncrementField = $incrementField;
> return $this;
> }
> What do you think about?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Janich <jan... @gmail.com>
Date: Sun, 22 Jul 2012 01:09:18 -0700 (PDT)
Local: Sun, Jul 22 2012 4:09 am
Subject: Re: Support IGNORE clause for INSERT
From a quick search, it doesnt look like MSSQL supports this either, so it would seem a very MySQL specific case.
But there are other ways to do it. Try check this thread out for inspiration on alternatives: http://stackoverflow.com/questions/548541/insert-ignore-vs-insert-on-... (both MySQL and non-MySQL specific solutions there)
/ Janich
On Saturday, 21 July 2012 20:37:59 UTC+2, Aerendir wrote:
> Hi at all, > this is my first post on this group, so excuse me for any error of any > kind :)
> I'm developing an app using Joomla! Platform 12.1 and i need to use IGNORE > clause for a set of multiple insert.
> Actually, the framework doesn't support the use of this clause, but, > reading the code, it seems quite simple to add it.
> If i'm not wrong it could be sufficient to edit the method insert of the > JDatabaseQuery class (joomla/database/query.php).
> Now the function is this:
> *public function **insert*($table, $incrementField*=**false*) > { > $this*->*type *=* 'insert'; > $this*->*insert *= new *JDatabaseQueryElement('INSERT INTO', $table); > $this*->*autoIncrementField *= *$incrementField;
> *return *$this; > }
> I think (but i could be wrong! I don't yet fully know the logic of the > entire database package) that the function could be rewrote in this way:
> *public function **insert*($table, $incrementField*=**false*, $ignore=* > false*) > { > $this*->*type *=* 'insert';
> *if*($ignore) > { > $this*->*insert *= new *JDatabaseQueryElement('INSERT IGNORE INTO', $table > ); > } > *else > *{ > $this*->*insert *= new *JDatabaseQueryElement('INSERT INTO', $table); > }
> $this*->*autoIncrementField *= *$incrementField;
> *return *$this; > }
> What do you think about?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Aerendir <adamo.cre... @gmail.com>
Date: Sun, 22 Jul 2012 23:54:49 -0700 (PDT)
Local: Mon, Jul 23 2012 2:54 am
Subject: Re: Support IGNORE clause for INSERT
At this moment i'm working around the problem using a simple str_replace, something like:
$this*->*_dbo*->*setQuery(*str_replace*('INSERT INTO', 'INSERT IGNORE INTO', $query)); As Michael suggested, i tried to add an insert method to JDatabaseQueryMysql:
*public function **insertIgnore*($table)
{
$this*->*type *=* 'insert';
$this*->*insert *= new *JDatabaseQueryElement('INSERT IGNORE INTO', $table );
*return *$this;
}
It seems work well: the query is correctly built but i think, if interested
in, that someone else should try it.
Il giorno sabato 21 luglio 2012 20:37:59 UTC+2, Aerendir ha scritto:
> Hi at all, > this is my first post on this group, so excuse me for any error of any > kind :)
> I'm developing an app using Joomla! Platform 12.1 and i need to use IGNORE > clause for a set of multiple insert.
> Actually, the framework doesn't support the use of this clause, but, > reading the code, it seems quite simple to add it.
> If i'm not wrong it could be sufficient to edit the method insert of the > JDatabaseQuery class (joomla/database/query.php).
> Now the function is this:
> *public function **insert*($table, $incrementField*=**false*) > { > $this*->*type *=* 'insert'; > $this*->*insert *= new *JDatabaseQueryElement('INSERT INTO', $table); > $this*->*autoIncrementField *= *$incrementField;
> *return *$this; > }
> I think (but i could be wrong! I don't yet fully know the logic of the > entire database package) that the function could be rewrote in this way:
> *public function **insert*($table, $incrementField*=**false*, $ignore=* > false*) > { > $this*->*type *=* 'insert';
> *if*($ignore) > { > $this*->*insert *= new *JDatabaseQueryElement('INSERT IGNORE INTO', $table > ); > } > *else > *{ > $this*->*insert *= new *JDatabaseQueryElement('INSERT INTO', $table); > }
> $this*->*autoIncrementField *= *$incrementField;
> *return *$this; > }
> What do you think about?
You must
Sign in before you can post messages.
You do not have the permission required to post.