Esempio n. 1
0
 /**
  * @param \MORM\Entity $entity
  *
  * @return array
  */
 public function getType(\MORM\Entity $entity)
 {
     $result = [];
     $datatype = $this->getDataType();
     if (!empty($datatype)) {
         foreach ($datatype as $key => $value) {
             $data = $entity->get($key);
             switch ($value) {
                 case self::ARRAY:
                     if (is_array($data)) {
                         $data = @serialize($data);
                     }
                     break;
                 case self::JSON_ARRAY:
                     if (is_array($data)) {
                         $data = @json_encode($data);
                     }
                     break;
                 case self::DATE:
                     if (is_object($data)) {
                         if (get_class($data) === 'DateTime') {
                             $data = $data->format('Y-m-d');
                         }
                     }
                     break;
                 case self::DATETIME:
                     if (is_object($data)) {
                         if (get_class($data) === 'DateTime') {
                             $data = $data->format('Y-m-d H:i:s');
                         }
                     }
                     break;
             }
             $result[$key] = $data;
         }
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * @param \MORM\Entity $entity
  *
  * @return
  */
 public function remove(\MORM\Entity $entity)
 {
     $result = [];
     $data = $entity->getData();
     $table = $entity->getTable();
     $array = $entity->getType($entity);
     $result = $this->getQL()->deleteOne($table, $array);
     $entity = null;
     return;
 }