This topic is locked

0000-00-00 in date field

2/6/2007 1:34:11 PM
PHPRunner General questions
samsp author

Hi forum,
i use phprunner since 2 years, and i am happy with.
only sometimes i have questions and they are answered here very fast. thank you for that.
now my new problem:
i have a field named: publish_down. type: date. i like to have the possibility to insered "0000-00-00" for never. i tryed out null and not null fieldsetting in the database but i get a error when add a new dataset. default value set is 0000-00-00. how can i realize that.
thank you for answering
samsp

Alexey admin 2/7/2007

Hi,
I recommend you using NULL values instead of 0000-00-00 to indicate "never".
Of course you field must have NULL attribute.
Show me the error messages you get when adding a record.

samsp author 2/7/2007

hi Alexey,
thank you for the answer.
when i set the mysql datafield to ALLOW NULL and i write 0000-00-00 in the date field from _add.php i do not have this in my field but "NULL".

in my mysql database is a default value "0000-00-00". i need this value because i wrote a search function looking for 0000-00-00. and when i write manually the zero string in the database then _edit.php erase that and i have a "NULL" again. i think _add.php and _edit.php do not do that. hope you anderstand what i like to have.
greetings from spain
samsp

Alexey admin 2/7/2007

Hi,
PHPRunner converts all unusual DATE input to NULL.

You can overcome this using events.
Put this code to Before record added/updated events:

if(!$values["Date"])

$values["Date"]="0000-00-00";


where Date is your actual field name.

samsp author 2/7/2007

hi Alexey,
thank you for the answer. it works.
you make a good job.
greetings
samsp