Yii Framework Forum: Pesan Error Saat Nyimpen Data Input Tipe Tanggal di YII - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Pesan Error Saat Nyimpen Data Input Tipe Tanggal di YII Pesan Error Saat Nyimpen Data Input Tipe Tanggal di YII Rate Topic: -----

#1 User is offline   aceng 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 27-June 12

Posted 27 June 2012 - 02:51 AM

Bagai mana cara menangani datetime di YII untuk bisa disimpan ke MySQL:
Setting yang sudah dilakukan:

1. file rootapp/index.php:
date_default_timezone_set('Asia/Jakarta');
atau
date_default_timezone_set('UTC');
::hasilnya sama saja error

2. di file rootapp/modul1/_form.php
input pakai date timepicker

3. contoh input tanggal setelah dijalankan:
-cara input langsung kekotak tgl :
01-01-2012
01-01-12
2012-01-01
12-01-01
-atau cara dengan datetimepicker
-hasilnya tetap error..

---------------
Error :
CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '' for column 'dtgl_catat' at row 1. The SQL statement executed was: INSERT INTO `asr_polis`.....
..
..
C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\yii\framework\db\CDbCommand.php(354)
---------------
Pertanyaannya apa yang harus dilakukan agar data inputan yii bisa masuk ke database mysql...
Terima kasih...
0

#2 User is offline   aceng 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 27-June 12

Posted 27 June 2012 - 04:30 AM

Jawabnnya:

Ganti array di function rules dari 'safe' menjadi "'default', 'value'=>NULL"

1. cari file \rootapp\modul1\protected\models\test.php
2. cari function dan tipe tanggal yang mau di ubah sbb:
public function rules()
{
..
..
asal :
array('dtgl1', 'safe'),
ganti dengan :
array('dtgl1', 'default', 'value'=>NULL),
..
..
2. simpan dan test aplikasi anda...
0

#3 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 197
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 03 July 2012 - 08:59 PM

wah , klo sayah mah untuk tipe tanggal di mysql selalu pake varchar. soalnya klo gabung 2 database yang berbeda , misal mysql-oracle supaya gak terlalu ribet. hehehe...maklum masih newbie sayah mah ^_^
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users