1
Mazar
I am having problem with date and time insertion in xoops database
  • 2009/8/25 8:28

  • Mazar

  • Not too shy to talk

  • Posts: 191

  • Since: 2009/1/4 0


my XOOPS form
$form->addElement(new XoopsFormDateTime(_AM_MEDICAL_BOOKINGS_TIME'bookings_date'""));


My class 
$this->initVar("bookings_date",XOBJ_DTYPE_INT,null,false,10);

database field name is 
bookings_date      int
(11Mot NULL,
bookings_time      int(11Mot NULL,


when i am submitting it is inserting all the data except date and time

2
kaotik
Re: I am having problem with date and time insertion in xoops database
  • 2009/8/25 9:03

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


I don't know if the error comes from this:

This:
bookings_date      int(11Mot NULL,

Should be this:
bookings_date      int(11Not NULL,


Replace "Mot" with "Not".

3
Mazar
Re: I am having problem with date and time insertion in xoops database
  • 2009/8/25 9:16

  • Mazar

  • Not too shy to talk

  • Posts: 191

  • Since: 2009/1/4 0


ok that was mot was a mistake here. but it is correct in here

my print_r post shows date and time in another array
somehting like
Array ( [bookings] => 1 [bookings_date] => Array ( [date] => 2009-08-25 [time] => 44400 ) [bookings_description] => sdfadsfasdf

this is my insert code

$booking_handler =& xoops_getModuleHandler('medical_bookings''medical');
         
$obj $booking_handler->create();
        
$obj->setVars($_POST);
      if (!
$booking_handler->insert($obj)){
        
$msg _AM_BOKKING_MSG_ERROR;
    }else{
        
$msg _AM_BOOKIng_MSG_SUCCESS;
    }

4
kaotik
Re: I am having problem with date and time insertion in xoops database
  • 2009/8/25 9:44

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


Regarding bookings_date: One problem is you have fields set as integers on MySQL ( int(11) ) and your trying to save characters other then numbers in them.
2 solutions:
- Change type from int to varchar
- Save date as: "20090825"
Regarding bookings_time: Data is probably not being passed correctly to the handler. Try building a simple query and see if it gets inserted.

5
ghia
Re: I am having problem with date and time insertion in xoops database
  • 2009/8/25 12:16

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


The obvious datatype for storing this in the database would be datetime or timestamp.

Login

Who's Online

352 user(s) are online (219 user(s) are browsing Support Forums)


Members: 0


Guests: 352


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits