Cakephp date input issue - cakephp

I not 100% sure why this is happening, however, the issue I am having is that I have a very simple date input which works perfectly fine on my home server (generates a dropdown list of Years, Months, Days). When I upload it to a remote server, an input field appears instead of a dropdown.
On the remote server I have tried both DATE and DATETIME fields in the database both producing the same results.
Here is the basic code:
echo $this->Form->input('event_date');
The version of cake is 1.3 (if that makes any difference).

Just remove all the files in your app/tmp directory.
Cakephp will take the structure of tables to the cache.
Whenever you are making changes to database table structure, you have to clear the cache.

Related

How to avoid the "Z" in my PostgreSQL datetime

I am using the material-UI to select a date and store it in a SQL Database. When I send the date to the DB it is in this format "YYYY-MM-DDTHH:MM" for example "2017-05-24T10:30". However when I fetch the dates from the DB they come out like this "YYYY-MM-DDTHH:MM:SS.000Z" for example "2019-06-14T10:30:00.000Z"
Now I am using a calendar package called FullCalendar, which interprets the "Z" as -5H. So all of the dates on my calendar are moved back 5H. The really bazaar thing is that this only happens when the app is deployed on Heroku. If I run the app locally and try to fetch the dates the database is automatically adding 5H to the times to compensate for the "Z" and the dates are displayed correctly on the calendar.
I'm looking for a solution to either get rid of the "Z" or make the heroku and local app deployments consistent.
I'm not sure if there is any relevant code to include here. The POST and GET methods to the DB are pretty standard. Let me know if I can add anything that might be of use.
Without more information, this will be the easy solution (not the best):
SELECT LEFT(cast('2019-06-14T10:30:00.000Z' AS varchar),16)
Result: "2019-06-14T10:30"
Look at these functions for better answers in terms of performance: AT TIME ZONE, date_trunc
https://www.postgresql.org/docs/9.1/functions-datetime.html

Cannot export local databases using phpmyadmin

Environment:
Windows 10
XAMPP Win32 7.0.23
PHP: 7.0.23
MariaDB 10.1.28?
Magento 2.1.9
I cannot export any databases. I get that "Warning: a form on this page has more than 1000 fields" message, and then the export does not work. From what I've read, you're supposed to change the max_input_vars in php.ini. I checked my only php.ini file. The line was commented out. I removed the semicolon and increased the value - a few times. Here is what it looks like now:
; How many GET/POST/COOKIE input variables may be accepted
max_input_vars = 10000
No matter what I increased it to, I still get the same 1,000 fields message when I try to export a database. I searched the entire XAMPP directory and sub-directories, but found no other php.ini except for the one in the xampp/php directory. I would not think it needs to be higher than 10,000 for a fairly new Magento database with only a few products in it. When I imported the database into XAMPP, it was less than 2 MB in total size. I tried exporting another Magento database for the unmodified demo site, and I get the same warning and result.
Can someone help me? Thanks.
UPDATE:
info.php created and verifies the current max_input_vars = 10000. I am selecting the database in phpmyadmin, and then clicking on the export button at the top. The export, in simple mode, selects all tables for the given database for export.
put info.php into document root with
<?php
phpinfo();
?>
call the file in browser and check the value for max_input_vars.
Also specify if you are exporting a whole database or a query result for further advice

Clearing the cakephp tmp/cache solves the issue for only one save call. What can be the reason?

I modified the schema of mysql database(added a new table etc.), I cleared the tmp/cache(except directories).
Now the save in the new table happens only once(I have multiple save calls in a for loop and save happens for all of them) and fails from next time I enter the flow.
I am using cakephp 1.3.
What else should I check ?
Got it.
The cache issue was one part of the problem, which got fixed by clearing the files in tmp/cache directory.
Learning is -
If you make mysql schema changes(add new table / column etc.) in mysql, either clear the tmp/cache directory or set the debug level as 3 and refresh the page and set the debug level again to 0(if on production).
I was also getting a save error - mysql server has gone away, because in configs the wait_timeout value was 600 seconds. But my script was taking longer than that.
So model->save() was not working.
In my.cnf I updated the timeout to 4800 and restarted mysql and it fixed the problem.

cakephp database table not found error after copied to local

i am using cakephp 1.3 ...it was working like charm in server ,i copied it to local and executed it....after that it shows a wierd error .It says "Missing Database Table
Error: Database table inboxes for model Inbox was not found.
Notice: If you want to customize this error message, create app/views/errors/missing_table.ctp
"
things i did after copying to local:
i used same DB with different name (yes..i changed in database.php too)
But there exist table "inbox"
I tried these ways:
1.removed inbox model and controller--nothing hapened
2.removed cache file from app/tmp/cache/models ---nothing happened
3.disabled caching from core.php
when i used another table with same name as in server its working
But nothing seems to be working after i used another database name as i am using that db name for another app ....can anyone help me on this...whats really happening with this.,its urgent..thanks in advance...
As Joseph mentioned in the comment, it may be a spelling mistake. But there could be one more reason:
On the web servers sometimes (mostly on shared hosting) you have the database name prefix. So it is possible that the real name of the database on your server is different from the database on your localhost. You can configure this in your app folder config/database.php
Best regards,
Tony.
After days of headache i sorted it out.
Even if i was using same DB with different name,it was using different encoding .I created new db with uttf_genereal_ci encoding and imported old one into it.Now its working like charm.Thanks guys for helping me on this

Django DatabaseError - What is the best way to debug?

I'm having some trouble with a django database (postgresql backend).There was a model (a profile for users) in the project with some boilerplate stuff in it. This has sat in our project for a while, not being used. I actually got round to needing this, so I adjusted the models and created some initial migrations with South. On my dev box I dropped the entire db and syncdb'ed and migrated. This worked fine.
When I've pushed this out to production, I manually removed the old tables in postgresql and syncdb'ed and migrated. However, in my admin interface a DatabaseError is raised as some function is looking for a field on the old model. I've even dropped the entire postgresql database and syncdb'ed / migrated again and this still happens. The offendinging field is called gender (not one that I created). The migration works, and the database structure reflects my models, but for some reason the admin interface wants to find this (non-existant) gender field. This is the error:
DatabaseError: column user_profiles.gender does not exist LINE 1: ... "user_profiles"."id", "user_profiles"."user_id", "user_prof...
I understand this seems to be quite site specific, but perhaps I could get some pointers on how to debug this?
Thanks
If I understand your problem, your current code should not contain a reference to "gender" any more, since the old code was removed. Try to find a source file which still contains it:
find your-dir -name '*.py'|xargs grep gender
Or there is a pyc file, but the py file was removed. But Python still loads the pyc file....
If this does not help, please post the ascii traceback.

Resources