diff --git a/resources/classes/orm.php b/resources/classes/orm.php
index 5d42efdd78..5141215b6b 100644
--- a/resources/classes/orm.php
+++ b/resources/classes/orm.php
@@ -114,7 +114,7 @@
}
//order by
if (is_array($array['order_by'])) {
- $sql .= "order by ".$array['order_by']." ";
+ $sql .= "ORDER BY ".$array['order_by']." ";
}
//limit
if (isset($array['limit'])) {
@@ -260,7 +260,9 @@
$depth = $this->array_depth($array);
//before normalizing the array
//echo "before: ".$depth."
\n";
+ //echo "
\n"; //print_r($array); + //echo "\n"; //normalize the array if ($depth == 1) { $return_array[$name][] = $array; @@ -273,9 +275,11 @@ } unset($array); //after normalizing the array - //$depth = $this->array_depth($main_array); + $depth = $this->array_depth($new_array); //echo "after: ".$depth."
\n"; + //print_r($new_array); + //echo "\n"; //return the array return $return_array; } @@ -294,8 +298,9 @@ } //normalize the array structure - $main_array = $this->normalize_array($array, $this->name); - unset($array); + //$new_array = $this->normalize_array($array, $this->name); + //unset($array); + $new_array = $array; //connect to the database if needed if (!$this->db) { @@ -306,19 +311,19 @@ $this->debug["sql"] = true; //start the atomic transaction -// $this->db->beginTransaction(); + $this->db->beginTransaction(); //debug info //echo "
\n"; - //print_r($main_array); + //print_r($new_array); //echo "\n"; //exit; //loop through the array - foreach ($main_array as $schema_name => $schema_array) { - $this->name = $schema_name; + foreach ($new_array as $schema_name => $schema_array) { - foreach ($schema_array as $schema_key => $array) { + $this->name = $schema_name; + foreach ($schema_array as $schema_id => $array) { //set the variables $table_name = "v_".$this->name; @@ -359,7 +364,7 @@ //get the data try { $prep_statement->execute(); - $parent_array = $prep_statement->fetch(PDO::FETCH_ASSOC); + $result = $prep_statement->fetch(PDO::FETCH_ASSOC); } catch(PDOException $e) { echo 'Caught exception: ', $e->getMessage(), "
\n"; + //print_r($old_array); + //echo "\n"; + //exit; } - //$message["new"] = $main_array; - //$message["new"]["md5"] = md5(json_encode($main_array)); + //$message["new"] = $new_array; + //$message["new"]["md5"] = md5(json_encode($new_array)); $this->message = $message; //commit the atomic transaction -// $this->db->commit(); + $this->db->commit(); //get the domain uuid $domain_uuid = $_SESSION['domain_uuid']; //log the transaction results -/* - $sql = "insert into v_database_transactions "; - $sql .= "("; - $sql .= "database_transaction_uuid, "; - $sql .= "domain_uuid, "; - $sql .= "user_uuid, "; - if (isset($this->app_uuid)) { - $sql .= "app_uuid, "; + if (file_exists($_SERVER["PROJECT_ROOT"]."/app/database_transactions/app_config.php")) { + $sql = "insert into v_database_transactions "; + $sql .= "("; + $sql .= "database_transaction_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "user_uuid, "; + if (isset($this->app_uuid)) { + $sql .= "app_uuid, "; + } + $sql .= "app_name, "; + $sql .= "transaction_code, "; + $sql .= "transaction_address, "; + //$sql .= "transaction_type, "; + $sql .= "transaction_date, "; + $sql .= "transaction_old, "; + $sql .= "transaction_new, "; + $sql .= "transaction_result "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'".$domain_uuid."', "; + $sql .= "'".$_SESSION['user_uuid']."', "; + if (isset($this->app_uuid)) { + $sql .= "'".$this->app_uuid."', "; + } + $sql .= "'".$this->app_name."', "; + $sql .= "'".$message["code"]."', "; + $sql .= "'".$_SERVER['REMOTE_ADDR']."', "; + //$sql .= "'$transaction_type', "; + $sql .= "now(), "; + $sql .= "'".json_encode($old_array, JSON_PRETTY_PRINT)."', "; + $sql .= "'".json_encode($new_array, JSON_PRETTY_PRINT)."', "; + $sql .= "'".check_str(json_encode($this->message, JSON_PRETTY_PRINT))."' "; + $sql .= ")"; + $this->db->exec(check_sql($sql)); + unset($sql); } - $sql .= "app_name, "; - $sql .= "transaction_code, "; - $sql .= "transaction_address, "; - //$sql .= "transaction_type, "; - $sql .= "transaction_date, "; - $sql .= "transaction_before, "; - $sql .= "transaction_after, "; - $sql .= "transaction_result "; - $sql .= ")"; - $sql .= "values "; - $sql .= "("; - $sql .= "'".uuid()."', "; - $sql .= "'".$domain_uuid."', "; - $sql .= "'".$_SESSION['user_uuid']."', "; - if (isset($this->app_uuid)) { - $sql .= "'".$this->app_uuid."', "; - } - - $sql .= "'".$this->app_name."', "; - $sql .= "'".$message["code"]."', "; - $sql .= "'".$_SERVER['REMOTE_ADDR']."', "; - //$sql .= "'$transaction_type', "; - $sql .= "now(), "; - $sql .= "'".json_encode($parent_array, JSON_PRETTY_PRINT)."', "; - $sql .= "'".json_encode($main_array, JSON_PRETTY_PRINT)."', "; - $sql .= "'".check_str(json_encode($this->message, JSON_PRETTY_PRINT))."' "; - $sql .= ")"; - $this->db->exec(check_sql($sql)); - unset($sql); -*/ } //save method //define singular function to convert a word in english to singular