Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Offline
Re: safe_insert using AND in the WHERE clause
Can you post the code that doesn’t work?
Offline
Re: safe_insert using AND in the WHERE clause
Here is the idea:
safe_upsert(
'txp_lang',
'data = "My data", event = "public"',
'name = "my_data" AND lang = "en-gb"'
)
Edit: … and here is the error message User_Error "Duplicate entry '0' for key 'lang'"
Edit#2: Here is the INSERT
command if the row does not exist:
[SQL: INSERT INTO txp_lang SET name = 'my_data' AND lang = 'en-gb', data = 'My data', event = 'public' ]
Last edited by NicolasGraph (2016-07-06 18:54:28)
Offline
Re: safe_insert using AND in the WHERE clause
safe_insert('txp_lang', 'data = "My data", event = "public", name = "my_data", lang = "en-gb"');
Should work fine…
However, you’re using safe_upsert, which internally calls safe_insert, but can’t handle anything more then the most simple ‘where’ part. It’s a safe_upsert limitation. One could consider this a bug. If so, open an issue at github.
Offline
Re: safe_insert using AND in the WHERE clause
ruud wrote #300218:
One could consider this a bug. If so, open an issue at github.
Thanks Ruud, I sent a pull request; let see what will happen…
Last edited by NicolasGraph (2016-07-07 06:36:04)
Offline