introduction of magic column names

thread: 20 messages  |  last: a year ago  |  started: thursday, august 24, 2006, 11:29 pm pdt


#1  |  Andre L. (Berlin) Germany
Thursday, August 24, 2006, 11:29 PM PDT

Hi everybody,

I was wondering if you are thinking about introducing some 'magic field names' like they are available in rails.

http://wiki.rubyonrails.org/rails/pages/MagicFieldNames

It is quite straight forward to add the handling of updated_on and created_on into the template and my uestion is, if this is something worth adding to the core functionality.

Just my 2 cent.

Best regards,
A.L.

#2  |  Gavin Sinai (London, England) South Africa
Friday, August 25, 2006, 1:18 AM PDT

There is a <http> operator for url links.

<http://wiki.rubyonrails.org/rails/pages/MagicFieldNames>

I agree that is straight forward to add to templates. Qcodo has been designed from the outside for customisability.

What concerns me about the magic fields is that they may clash with people's existing projects. Therefore, if they are placed in core functionality, there needs to be a way to disable them.

Btw, have you implemented any magic field names, and if you have, would you consider putting them in the downloads section?

Regards

Gavin

#3  |  Andre L. (Berlin) Germany
Friday, August 25, 2006, 5:37 AM PDT

Ok, I posted it here:

<http://www.qcodo.com/downloads/item.php/65>

However, I screwed up the title. Can you rename it to:
Automatically populating creation and modification dates

Best regards,
A.L.

#4  |  ByronH (Tzaneen, Limpopo) South Africa
Friday, August 25, 2006, 7:19 AM PDT

Hi there,

This is definitely a useful function but the field names would need to be carefully considered.
In my current project I have used this naming convention:

meta_recorded
meta_modified
meta_valid_record

Etc.

Perhaps QCodo could utilise something similar:

qmeta_created
qmeta_modified
qmeta_dirty_record

Etc.
I'm sure that this would make it easy to add magic fields that won't clash with existing projects, and it will make meta fields readily identifiable for hiding in datagrids, etc...

Btw, I've noticed that the post code hints have disappeared...

#5  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Friday, August 25, 2006, 9:33 AM PDT

Moschen... thanks for your contribution.  I've gone ahead and renamed it as you asked.

Visor, what are you referring to when you say that the “post code hints have disappeared”?

Finally, while I think that this is very useful functionality (i'll likely use it myself!), in general I think it's a good philosophy to have the core templates which are distributed with qcodo do as little modification to the pure data as possible, just so that devs (especially newbies) aren't surprised by anything.

As Gavin points out, the power of Qcodo is to be able to customize/override anything, including templates -- so i think your custom object_save.tpl is a great modification which everyone can take advantage of... but i think for now, we'll leave it as an optional add-on for people to use if they wish.

Thanks for sharing it with the community!

#6  |  ByronH (Tzaneen, Limpopo) South Africa
Monday, August 28, 2006, 12:56 AM PDT

Hi Mike,

The “post code hints” (not the best desription, I know) I'm referring to are the tags one types in a post like
.bc

, etc.
These used to appear above the post area but are no longer there. I mentioned this because Gavin pointed out the <http> operator for URLS but new users wouldn't be aware of these...

#7  |  Gavin Sinai (London, England) South Africa
Monday, August 28, 2006, 2:02 AM PDT

Moschen, thanks for that piece of code. I will definitely be using it in upcoming applications - but with the magic column names changed to suit my needs of course.

I guess I like configuration better than convention.

Regards

Gavin

#8  |  ByronH (Tzaneen, Limpopo) South Africa
Monday, August 28, 2006, 2:49 AM PDT

Yup, thanx Moschen, definitely adding that one to my toolkit :)

PS: Seems to require the DATETIME type, doesn't appear to like TIMESTAMP.

#9  |  Andre L. (Berlin) Germany
Tuesday, August 29, 2006, 4:14 AM PDT

Hi everybody,

as I wasn't too happy with my first solution (it was just not generic enough :-) ), I spend some more time on it and would like to know your opinion.

Here is the new approach:

There will be two new variables that you can set in your _configuration.inc:

// Define column name which will be used to automatically set the last modification timestamp.
// The framework will automatically use that column, when it is available. If it is not available
// in a table, it will be ignored.
define('MAGIC_COLUMN_NAME_MODIFICATION_DATE','modification_date');

// Like MAGIC_COLUMN_NAME_MODIFICATION_DATE, only that this timestamp will be set on creation of
// a new record.
define('MAGIC_COLUMN_NAME_CREATION_DATE','creation_date');

The new object_save.tpl template will then pick up this information and generate the code for filling these columns if they are defined.

I think this way it's much easier. If you want I can upload the script as a new version.

Best regards,
A.L.

#10  |  ByronH (Tzaneen, Limpopo) South Africa
Tuesday, August 29, 2006, 4:27 AM PDT

Great stuff! I like this implementation better :)



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.