コード例 #1
0
ファイル: JsonStore.php プロジェクト: jivoo/core
 /**
  * {@inheritdoc}
  */
 protected function encode(array $data)
 {
     if ($this->prettyPrint) {
         return Json::prettyPrint($data);
     }
     return Json::encode($data);
 }
コード例 #2
0
ファイル: MysqlTypeAdapter.php プロジェクト: jivoo/data
 /**
  * {@inheritdoc}
  */
 public function encode(DataType $type, $value)
 {
     $value = $type->convert($value);
     if (!isset($value)) {
         return 'NULL';
     }
     switch ($type->type) {
         case DataType::INTEGER:
             return intval($value);
         case DataType::FLOAT:
             return floatval($value);
         case DataType::BOOLEAN:
             return $value ? 1 : 0;
         case DataType::DATE:
             return $this->db->quoteString(gmdate('Y-m-d', $value));
         case DataType::DATETIME:
             return $this->db->quoteString(gmdate('Y-m-d H:i:s', $value));
         case DataType::STRING:
         case DataType::TEXT:
         case DataType::BINARY:
         case DataType::ENUM:
             return $this->db->quoteString($value);
         case DataType::OBJECT:
             return $this->db->quoteString(Json::encode($value));
     }
 }