Open caleb99 opened 8 years ago
Ya makes sense. I had similar thought as well, but wanted to first get a working version first.
We could also switch to embedded wpdb functions for table manipulation.
https://codex.wordpress.org/Class_Reference/wpdb
$wpdb->insert(
'table',
array(
'column1' => 'value1',
'column2' => 123
),
array(
'%s',
'%d'
)
);
Could be something like:
$wpdb->insert(
tn('client_transactions'),
fields('client_transactions', $user_input), // fields could be array_mapped somehow
input_types('client_transactions') // returns the wpdb->prepare specific input types
);
https://github.com/achhunna/Tally/blob/master/tally-functions.php#L15-L19
I'm wondering if we can't create more of a data structure for the purposes of defining tables.
We'll need to do strong type casting / validations. i.e. every input validated before being passed to an insert table helper function.
Maybe something like (pseudo code):
Then we can make helper functions to reference the tables and their attributes: