Example #1
0
 public function testStoreObject()
 {
     $object = new \StdClass();
     $object->foo = "bar";
     $different_object = new \StdClass();
     $different_object->hello = "there";
     $model = new TestModel();
     $model->date_field = date("Y-m-d H:i:s");
     $model->integer_field = 1;
     $model->text_field = $object;
     $model->save();
     $reload = TestModel::search()->where('test_model_id', $model->test_model_id)->execOne();
     $this->assertEquals(JsonPrettyPrinter::Json($object), $reload->text_field);
     // TODO: This should really be returning a deserialised blob.
     $reload->text_field = $different_object;
     $reload->save();
     $reload_again = TestModel::search()->where('test_model_id', $model->test_model_id)->execOne();
     $this->assertEquals(JsonPrettyPrinter::Json($different_object), $reload_again->text_field);
 }
Example #2
0
 public function processUpdate(DatabaseLayer\Update $thing)
 {
     // SELECTORS
     if (count($thing->getTables()) > 1) {
         throw new Exception("Active Record Cannot update into more than one table at a time!");
     }
     $tables = $thing->getTables();
     $table = end($tables);
     $updates = array();
     foreach ($thing->getData() as $key => $value) {
         $key = trim($key, "\"");
         if (is_object($value) || is_array($value)) {
             $value = JsonPrettyPrinter::Json($value);
         }
         $value_slashed = addslashes($value);
         if ($value === null) {
             $updates[] = "\"{$key}\" = NULL";
         } else {
             $updates[] = "\"{$key}\" = \"{$value_slashed}\"";
         }
     }
     $selector = "UPDATE {$table->getName()} ";
     $data = "SET " . implode(", ", $updates);
     $conditions = $this->processConditions($thing);
     $query = "{$selector}\n{$data}\n{$conditions}";
     //header("Content-type: text/plain"); echo $query; exit;
     $result = $this->query($query);
     return $result->errorCode() == "00000" ? true : false;
 }
 /**
  * @Route("/packages/show-result")
  */
 public function showResultAction()
 {
     $json = JsonPrettyPrinter::Json($this->getSatisJson());
     return $this->render('default/show-result.html.twig', array('json' => $json));
 }
Example #4
0
 public function __toJson($anticipated_rows = null)
 {
     $array = $this->__toArray($anticipated_rows);
     return JsonPrettyPrinter::Json($array);
 }