|
@@ -15,9 +15,10 @@
|
|
|
namespace Cake\Database\Type;
|
|
namespace Cake\Database\Type;
|
|
|
|
|
|
|
|
use Cake\Database\Driver;
|
|
use Cake\Database\Driver;
|
|
|
-use Cake\Database\Type;
|
|
|
|
|
|
|
+use Cake\Database\TypeInterface;
|
|
|
use DateTimeInterface;
|
|
use DateTimeInterface;
|
|
|
use Exception;
|
|
use Exception;
|
|
|
|
|
+use PDO;
|
|
|
use RuntimeException;
|
|
use RuntimeException;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -25,7 +26,7 @@ use RuntimeException;
|
|
|
*
|
|
*
|
|
|
* Use to convert datetime instances to strings & back.
|
|
* Use to convert datetime instances to strings & back.
|
|
|
*/
|
|
*/
|
|
|
-class DateTimeType extends Type
|
|
|
|
|
|
|
+class DateTimeType implements TypeInterface
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -77,11 +78,18 @@ class DateTimeType extends Type
|
|
|
protected $_className;
|
|
protected $_className;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * Identifier name for this type
|
|
|
|
|
+ *
|
|
|
|
|
+ * @var string
|
|
|
|
|
+ */
|
|
|
|
|
+ protected $_name = null;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* {@inheritDoc}
|
|
* {@inheritDoc}
|
|
|
*/
|
|
*/
|
|
|
public function __construct($name = null)
|
|
public function __construct($name = null)
|
|
|
{
|
|
{
|
|
|
- parent::__construct($name);
|
|
|
|
|
|
|
+ $this->_name = $name;
|
|
|
$this->_setClassName(static::$dateTimeClass, 'DateTime');
|
|
$this->_setClassName(static::$dateTimeClass, 'DateTime');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -273,7 +281,7 @@ class DateTimeType extends Type
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Converts a string into a DateTime object after parseing it using the locale
|
|
|
|
|
|
|
+ * Converts a string into a DateTime object after parsing it using the locale
|
|
|
* aware parser with the specified format.
|
|
* aware parser with the specified format.
|
|
|
*
|
|
*
|
|
|
* @param string $value The value to parse and convert to an object.
|
|
* @param string $value The value to parse and convert to an object.
|
|
@@ -285,4 +293,17 @@ class DateTimeType extends Type
|
|
|
|
|
|
|
|
return $class::parseDateTime($value, $this->_localeFormat);
|
|
return $class::parseDateTime($value, $this->_localeFormat);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Casts given value to Statement equivalent
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param mixed $value value to be converted to PDO statement
|
|
|
|
|
+ * @param \Cake\Database\Driver $driver object from which database preferences and configuration will be extracted
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return mixed
|
|
|
|
|
+ */
|
|
|
|
|
+ public function toStatement($value, Driver $driver)
|
|
|
|
|
+ {
|
|
|
|
|
+ return PDO::PARAM_STR;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|