diff --git a/src/mockup/go_text_templates/ctrl.txt b/src/mockup/go_text_templates/ctrl.txt
index cc14747..69f4305 100644
--- a/src/mockup/go_text_templates/ctrl.txt
+++ b/src/mockup/go_text_templates/ctrl.txt
@@ -1,5 +1,7 @@
[
'input' => INPUTS::post,
@@ -18,7 +21,9 @@ class {{.File}}_in {
'html' => HTML_FLAG::escape,
'rule' => 'required|max: 75', // Others: email, valid_email_domain,
// min, max, between, same, secure (password), alphanumeric
- 'message' => ['required' => 'Must fill out first_name!']
+ 'message' => ['required' => 'Must fill out first_name!'],
+ 'db' => DB_FILTER::OFF, // Should be used on Login Data only
+ 'skip_db' => false // Should not save?
],
'last_name' =>
[
@@ -26,11 +31,10 @@ class {{.File}}_in {
'field' => FIELD_FILTER::raw_string,
'html' => HTML_FLAG::escape,
'rule' => 'required|max: 75',
- 'message' => ['required' => 'Must fill out last_name!']
+ 'message' => ['required' => 'Must fill out last_name!'],
+ 'db' => DB_FILTER::OFF // Should be used on Login Data only
],
- ]);
-
- return $safer_data; // Makes an Array of: fields, html, and errrors
+ ];
}
}
diff --git a/src/mockup/go_text_templates/models.txt b/src/mockup/go_text_templates/models.txt
index d3164c4..0877710 100644
--- a/src/mockup/go_text_templates/models.txt
+++ b/src/mockup/go_text_templates/models.txt
@@ -1,10 +1,13 @@
dbh = $dbh;
@@ -42,7 +45,7 @@ class {{.File}}_model {
}
public function save_{{.Method}}(array $input): bool {
- $set = $this->db_helper->set_members_by_array($input);
+ $set = $this->db_helper->set_members_by_generator($input);
if ($set === false) {
return false; // Found Validation issues in input
}
@@ -64,7 +67,7 @@ class {{.File}}_model {
try {
$sql = "SELECT * FROM {$this->demo_table} LIMIT {$number_of_users_to_get}";
$result = $this->dbh->query($sql);
- return \tts\database\help_load::fetch_lazy($result);
+ return \tts\database\help_load::pdo_fetch_lazy($result);
} catch (\PDOException $e) {
echo \tts\exceptions\DB_Exception::customMessage($e);
}
diff --git a/src/mockup/go_text_templates/outputs.txt b/src/mockup/go_text_templates/outputs.txt
index 30e6797..0094b48 100644
--- a/src/mockup/go_text_templates/outputs.txt
+++ b/src/mockup/go_text_templates/outputs.txt
@@ -1,17 +1,37 @@
+
Sample View file
[
'input' => INPUTS::post, // Others: post, json (REQUIRED param)
@@ -38,9 +38,7 @@ class home_in {
'rule' => 'greater_than: 18', //'number_range: 18, 24'
'message' => ['greater_than' => 'The %s must be an Adult over %d!'],
],
- ]);
-
- return $safer_data; // Makes an Array of: fields, html, and errrors
+ ];
}
}
\ No newline at end of file
diff --git a/src/mockup/models/app/home_model.php b/src/mockup/models/app/home_model.php
index 362cce8..3f305f5 100644
--- a/src/mockup/models/app/home_model.php
+++ b/src/mockup/models/app/home_model.php
@@ -63,7 +63,7 @@ class home_model {
}
public function save_new_user(array $input): bool {
- $set = $this->db_helper->set_members_by_array($input);
+ $set = $this->db_helper->set_members_by_generator($input);
if ($set === false) {
return false; // Found Validation issues in input
}
@@ -85,7 +85,7 @@ class home_model {
try {
$sql = "SELECT * FROM {$this->name_demo_table} LIMIT {$number_of_users_to_get}";
$result = $this->dbh->query($sql);
- return \tts\database\help_load::fetch_lazy($result);
+ return \tts\database\help_load::pdo_fetch_lazy($result);
} catch (\PDOException $e) {
echo \tts\exceptions\DB_Exception::customMessage($e);
}
diff --git a/src/mockup/outputs/app/home_out.php b/src/mockup/outputs/app/home_out.php
index 28efa1c..d3d971a 100644
--- a/src/mockup/outputs/app/home_out.php
+++ b/src/mockup/outputs/app/home_out.php
@@ -4,16 +4,34 @@ declare(strict_types=1);
namespace prj\mockup\outputs\app;
+use \tts\safer_io as SafeIO;
+
class home_out {
- public static function name_demo(array $input): array {
- $age = $input['html']['age'];
- $first_name = $input['html']['first_name'] ?? "Unknown";
- $last_name = $input['html']['last_name'] ?? "Unknown";
-
- $ret['main'] = ($input['errors']) ? "" : "Hello {$first_name} {$last_name}, You are {$age} years old!" . PHP_EOL;
- $ret['errors'] = $input['errors'];
+ public static function name_demo(array & $input): array {
$ret['model'] = $input['model'];
+ unset($input['model']); // Required to work, as sanitize cannot take an Object
+
+ $html_output = [];
+ $errors = [];
+ foreach(SafeIO::html_sanitize($input) as $html) {
+ $key = $html['name'] ?? "";
+ $html_output[$key] = $html['html'];
+
+ if (\tts\common::get_count($html['errors'])) {
+ $errors[$key] = $html['errors'][$key];
+ }
+ }
+
+ $age = $html_output['age'] ?? 0;
+ $first_name = $html_output['first_name'] ?? "Unknown";
+ $last_name = $html_output['last_name'] ?? "Unknown";
+
+ $ret['main'] = (\tts\common::get_count($errors)) ? "" : "Hello {$first_name} {$last_name}, You are {$age} years old!" . PHP_EOL;
+ $ret['errors'] = $errors;
+
+
+ unset($input); // Free up some space
return $ret;
}
@@ -37,7 +55,6 @@ class home_out {
}
\tts\html::show_table_from_generator(
['ID', 'First Name', 'Last Name', 'Age'],
- ['id', 'first_name', 'last_name', 'age'],
$input
);
}
diff --git a/src/mockup/views/default/app/name_demo_post.php b/src/mockup/views/default/app/name_demo_post.php
index a5cc565..e66ed60 100644
--- a/src/mockup/views/default/app/name_demo_post.php
+++ b/src/mockup/views/default/app/name_demo_post.php
@@ -1,6 +1,7 @@