I have 2 table :
table 1 : property
- ID
- Property Name
- LandLot
- Latest Comment ( function column, this will pull onnly 1 latest comment in table 2 )
Table 2 : property_comment
- id
- comment
- property => look up to table 1 - ID
How do i show Latest Comment ( function column, this will pull onnly 1 latest comment in table 2 )
thanks
Show latest comment from table Comment
Re: Show latest comment from table Comment
Hi,
what is the identifier to retrieve the latest comment?
what is the identifier to retrieve the latest comment?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Show latest comment from table Comment
Hi tmih,
I do not really understand what you are trying to do. I suppose to have a "latest" comment, you would also need a date/time identifier. If you have a field with that timestamp, you can so something like (code not tested)
Olaf
I do not really understand what you are trying to do. I suppose to have a "latest" comment, you would also need a date/time identifier. If you have a field with that timestamp, you can so something like (code not tested)
Code: Select all
select * from property_comment order by yourtimestampfield DESC limit 1
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: Show latest comment from table Comment
Hi,
There is no need for an additional column in this scenario. You can use the existing auto-increment id-column. The greater the id, the newer the record. So you'll have so sort DESCENDING.
But if you need for example the last modified comment, you should add a column "modified_on" (datetime), for example as Olaf has suggested. You can use the AppGini built-in default value "<%%editingDateTime%%>" for example
Best,
Jan
There is no need for an additional column in this scenario. You can use the existing auto-increment id-column. The greater the id, the newer the record. So you'll have so sort DESCENDING.
Code: Select all
SELECT *
FROM `comments`
WHERE `property_id` = 1
ORDER BY `id` DESC
LIMIT 1
Best,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Show latest comment from table Comment
Hi Jan,
I agree, but using a timestamp would enable to edit old records (and make an existing comment "newer").
Olaf
I agree, but using a timestamp would enable to edit old records (and make an existing comment "newer").
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: Show latest comment from table Comment
tks you i'm trying
Re: Show latest comment from table Comment
thank you, i know sql code but how do i add it to table view ?? thanks,can you give me an example
table 1 : property
- ID
- Property Name
- LandLot
- Latest Comment ( function column, this will pull onnly 1 latest comment in table 2 ) <<<<
table 1 : property
- ID
- Property Name
- LandLot
- Latest Comment ( function column, this will pull onnly 1 latest comment in table 2 ) <<<<
Re: Show latest comment from table Comment
table_view.php table_dml.php
Re: Show latest comment from table Comment
Hi,
in the hooks/property_comment.php (Assuming, property_comment is the table you are using for the comments)
add to the function property_comment_after_insert
and also to the function property_comment_after_update
This shall put the latest comment, or the latest edited comment to your poperty table.
in the hooks/property_comment.php (Assuming, property_comment is the table you are using for the comments)
add to the function property_comment_after_insert
and also to the function property_comment_after_update
Code: Select all
sqlvalue("update property set `Latest Comment` = '".$data['comment']."' where property.ID = '".$data['property']."'");
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.