a tiny mvc framework for php using php-activerecord
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fixed to properly handle date only fields

Kien La 75c9d852 abd59706

+33 -1
+11
lib/php-activerecord/lib/Connection.php
··· 389 389 } 390 390 391 391 /** 392 + * Return a date time formatted into the database's date format. 393 + * 394 + * @param DateTime $datetime The DateTime object 395 + * @return string 396 + */ 397 + public function date_to_string($datetime) 398 + { 399 + return $datetime->format('Y-m-d'); 400 + } 401 + 402 + /** 392 403 * Return a date time formatted into the database's datetime format. 393 404 * 394 405 * @param DateTime $datetime The DateTime object
+6 -1
lib/php-activerecord/lib/Table.php
··· 384 384 foreach ($hash as $name => &$value) 385 385 { 386 386 if ($value instanceof DateTime) 387 - $hash[$name] = $this->conn->datetime_to_string($value); 387 + { 388 + if ($this->columns[$name]->type == Column::DATE) 389 + $hash[$name] = $this->conn->date_to_string($value); 390 + else 391 + $hash[$name] = $this->conn->datetime_to_string($value); 392 + } 388 393 else 389 394 $hash[$name] = $value; 390 395 }
+5
lib/php-activerecord/lib/adapters/OciAdapter.php
··· 37 37 return "$sequence_name.nextval"; 38 38 } 39 39 40 + public function date_to_string($datetime) 41 + { 42 + return strtoupper($datetime->format('d-M-Y')); 43 + } 44 + 40 45 public function datetime_to_string($datetime) 41 46 { 42 47 return strtoupper($datetime->format('d-M-Y h:i:s A'));
+5
lib/php-activerecord/test/OciAdapterTest.php
··· 26 26 $this->assert_equals('01-JAN-2009 01:01:01 AM',$this->conn->datetime_to_string(date_create('2009-01-01 01:01:01 EST'))); 27 27 } 28 28 29 + public function test_date_to_string() 30 + { 31 + $this->assert_equals('01-JAN-2009',$this->conn->date_to_string(date_create('2009-01-01 01:01:01 EST'))); 32 + } 33 + 29 34 public function test_insert_id() {} 30 35 public function test_insert_id_with_params() {} 31 36 public function test_insert_id_should_return_explicitly_inserted_id() {}
+6
lib/php-activerecord/test/helpers/AdapterTest.php
··· 395 395 $datetime = '2009-01-01 01:01:01 EST'; 396 396 $this->assert_equals($datetime,$this->conn->datetime_to_string(date_create($datetime))); 397 397 } 398 + 399 + public function test_date_to_string() 400 + { 401 + $datetime = '2009-01-01'; 402 + $this->assert_equals($datetime,$this->conn->date_to_string(date_create($datetime))); 403 + } 398 404 } 399 405 ?>