<?php
run_query("INSERT INTO {$config['table_prefix']}cron (`description`, `thread_name`, `period`, `last_start_time`, `last_stop_time`, `command`) VALUES
('_remove_null_from_db_v4_', 'db_update', '1,15,30,45 19-23 * * *', now(), now(), '\$result = sql_query(\"SELECT * FROM information_schema.columns WHERE table_schema = \'\" . \$config[\'dbname\'] . \"\' AND \n    table_name LIKE \'\" . \$config[\'table_prefix\'] . \"%\' AND column_name != \'id\' AND data_type != \'enum\' AND column_default IS NULL\");\nwhile (\$field = sql_fetch_assoc(\$result)) {\n    if (\$field[\'DATA_TYPE\'] == \'decimal\' || \$field[\'DATA_TYPE\'] == \'float\' || strpos(\$field[\'DATA_TYPE\'], \'int\') !== false) {\n        \$field[\'COLUMN_DEFAULT\'] = \"0\";\n    } elseif (\$field[\'DATA_TYPE\'] == \'datetime\') {\n        \$field[\'COLUMN_DEFAULT\'] = \"\'0000-00-00 00:00:00\'\";\n    } else {\n        \$field[\'COLUMN_DEFAULT\'] = \"\'\'\";\n    }\n}\nsql_query(\"DELETE FROM \" . \$config[\'table_prefix\'] . \"cron WHERE description = \'_remove_null_from_db_v4_\'\");\nsql_query(\"DELETE FROM \" . \$config[\'table_prefix\'] . \"cron_queue WHERE thread_name = \'db_update\'\");')");