Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I have the following code which reads from sql tables that are not related to couch. These tables contain user data (basic name, email, telephone, address, city, state) that I am migrating from the old database to the new.

I am having an issue where it seems to cycle through the same query twice even though i have a limit set to 1.

Here is my code:

Code: Select all
<cms:query sql="select * from users" limit='1'>
    <cms:php>
        file_put_contents(".query.log", "- Email: <cms:show email />".PHP_EOL , FILE_APPEND | LOCK_EX);
    </cms:php>
</cms:query>


However inside my query log when I load the page that contains the above query code, I get two lines from the execution:
Code: Select all
- Email user@domain.com
- Email user@domain.com


When I do a <cms:dump /> before the <cms:php> it outputs only 1 record's data which is correct.

Any help is apprecaited.
@Blutbaden, something redirects your page one time, because there is no other explanation to the correct code.
I tested your piece and had no issue.

As to what does the redirect - could be anything from htaccess rules, code, user functions to a multi-lang addon that enforces a lang if page not accessed with lc. I wish I could help more on this issue, but you have to find the source of redirect.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Hi Trendoman,

If I gave you more info you may have solved it immediately.

I decided to move the code to another page and that solved the issue, there was definitely a redirect going on.

This code was on a back-end template that was only used to store data and not to produce any front-end pages. To run this code I was going to the back-end template and hitting View to access it from the couch admin, I guess there is a redirect here?

I moved the code to a page on the front end and accessed from the site and it only ran once when the page loaded.

Ty.
3 posts Page 1 of 1