Overview

Namespaces

  • cassandra
  • None
  • PHP
  • phpcassa
    • Batch
    • Connection
    • Index
    • Iterator
    • Schema
      • DataType
    • Util
    • UUID

Classes

  • AsciiType
  • BooleanType
  • BytesType
  • CassandraType
  • CompositeType
  • DateType
  • DoubleType
  • FloatType
  • Int32Type
  • IntegerType
  • LexicalUUIDType
  • LongType
  • TimeUUIDType
  • UTF8Type
  • UUIDType

Interfaces

  • Serialized
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: namespace phpcassa\Schema\DataType;
 3: 
 4: use phpcassa\Schema\DataType\LongType;
 5: use phpcassa\Schema\DataType\Serialized;
 6: 
 7: /**
 8:  * Stores a date as a number of milliseconds since the unix epoch.
 9:  *
10:  * @package phpcassa\Schema\DataType
11:  */
12: class DateType extends LongType implements Serialized {
13: 
14:     public function pack($value, $is_name=true, $slice_end=null, $is_data=false)
15:     {
16:         if (false !== strpos($value, ' ')) {
17:             list($usec, $sec) = explode(' ', $value);
18:             $value = $sec + $usec;
19:         } else if ($is_name && $is_data) {
20:             $value = unserialize($value);
21:         }
22: 
23:         $value = floor($value * 1e3);
24:         return parent::pack($value);
25:     }
26: 
27:     public function unpack($data, $handle_serialize=true)
28:     {
29:         $value = parent::unpack($data, false) / 1e3;
30:         if ($handle_serialize) {
31:             return serialize($value);
32:         } else {
33:             return $value;
34:         }
35:     }
36: }
37: 
phpcassa API documentation generated by ApiGen 2.8.0