Post by Joe1234 » Sun Jun 02, 2024 2:12 pm

I have a database table where I grab the contents that has accumulated, write it to a file, and then delete the contents. I delete the contents so I don't grab the same content next time.

The problem is, the way I created the script to write to that database, it checks the contents of the table before writing to the table to make sure I don't duplicate the contents, and by deleting the contents I essentially negate that safeguard.

What I need to do, that I don't know how or if it's possible, is to grab the contents from the last time the content was retrieved and not any of the stuff that was previously retrieved.

The initial way I'm thinking to achieve this is to write to a second table the last item retrieved and then query that item +1 to the end of the table. But I don't know how to query from one point to the end of a table.

Can someone show me how to accomplish this?
Last edited by Joe1234 on Mon Jun 03, 2024 7:13 am, edited 1 time in total.

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by nonnedelectari » Sun Jun 02, 2024 7:15 pm

Joe1234 wrote:
Sun Jun 02, 2024 2:12 pm
I have a database table where I grab the contents that has accumulated, write it to a file, and then delete the contents. I delete the contents so I don't grab the same content next time.

The problem is, the way I created the script to write to that database, it checks the contents of the table before writing to the table to make sure I don't duplicate the contents, and by deleting the contents I essentially negate that safeguard.

What I need to do, that I don't know how or if it's possible, is to grab the contents from the last time the content was retrieved and not any of the stuff that was previously retrieved.

The initial way I'm thinking to achieve this is to write to a second table the last item retrieved and then query that item +1 to the end of the table. But I don't know how to query from one point to the end of a table.

Can someone show me how to accomplish this?
Why don't you add a timestamp to those records and an indicator field "retrieved".

New member
Online

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by straightlight » Mon Jun 03, 2024 4:51 am

Joe1234 wrote:
Sun Jun 02, 2024 2:12 pm
I have a database table where I grab the contents that has accumulated, write it to a file, and then delete the contents. I delete the contents so I don't grab the same content next time.

The problem is, the way I created the script to write to that database, it checks the contents of the table before writing to the table to make sure I don't duplicate the contents, and by deleting the contents I essentially negate that safeguard.

What I need to do, that I don't know how or if it's possible, is to grab the contents from the last time the content was retrieved and not any of the stuff that was previously retrieved.

The initial way I'm thinking to achieve this is to write to a second table the last item retrieved and then query that item +1 to the end of the table. But I don't know how to query from one point to the end of a table.

Can someone show me how to accomplish this?
You don't need to add a second select statement to compare duplicated fields nor to add + 1 at the end on a second table to achieve this. This can be easily achieved by creating a new field in the same table with the default value of 0 and update the field from the table with the value of 1 once the row has been updated. A secondary method to ensure the row has been updated is by using: $this->db->countAffected() to see if the row has been successfully affected while running the script.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Joe1234 » Mon Jun 03, 2024 7:13 am

Thanks both.

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am
Who is online

Users browsing this forum: No registered users and 41 guests