Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Support IGNORE clause for INSERT
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
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:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Aerendir  
View profile  
 More options Jul 21 2012, 2:37 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Babker  
View profile  
 More options Jul 21 2012, 2:50 pm
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Moffatt  
View profile  
 More options Jul 21 2012, 3:19 pm
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Janich  
View profile  
 More options Jul 22 2012, 4:09 am
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aerendir  
View profile  
 More options Jul 23 2012, 2:54 am
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »