Update view when new record is inserted in a specific table
I'm doing an auctions website (not for any institution, just as pa开发者_运维技巧rt of my learning of php and cakephp). At Home page I have all the items displayed. What I need to do now is to refresh price / last licitation and time remaining in each item when any user makes a licitation.
So do you know how can I, in a view, keep watching licitations table for new records and then update those values in the view?
Attention: The new record in the database can be inserted by any other user.
Thanks.
You will have to use JavaScript to ask the server (your PHP script) if there are any changes, and then do the updating. You could use Comet for this. In short: Comet is a "technology" that allows you to be connected to the server constantly so that the server can send data to the client when said data is available (without the need to refresh a page).
You can either continuously refresh the page, or you can use AJAX to poll the server for changes and then update the page data. There is no good way to have the server notify the page directly - the page will have to ask about changes.
精彩评论