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".Joe1234 wrote: ↑Sun Jun 02, 2024 2:12 pmI 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.Joe1234 wrote: ↑Sun Jun 02, 2024 2:12 pmI 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?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: Google [Bot] and 27 guests