• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Condition Statement Builder?

#1
Question 
Is it safe to create a "conditional statement builder" for my custom upload page?

Here's an example:
The admin wants to update the userlist but she don't want to require some column upon upload.
Then 1 week had passed, and the requirements changed due to some reason. The admin now have to update the userlist but she wants to require some column. Then maybe next week, she will add a new condition that this column should be number only.

Did someone get my point? Hahahaha. I hope you understand what I want to happen.

I will be working on a conditional statement builder interface (consist of dropdowns, textboxes for custom inputs) that users can build a, you know, conditional statement:


Code:
Interface:
if [dropdown_fieldname] is [dropdown_comparison_text] to [dropdown_fieldname_or_value] then [dropdown_possible_options]

Ex:
if [first_name] is [not_equal] to ["Francis"] then [skip_row_upload]
Reply

#2
Am I getting this right, you want to upload CSV file that would update user records in DB? But you want to set conditions for what records would be updated?
Reply

#3
(07-11-2018, 03:55 AM)Pertti Wrote: Am I getting this right, you want to upload CSV file that would update user records in DB? But you want to set conditions for what records would be updated?

I want to set a condition/s that will be stored in the database.
So when I run the upload model, the custom rules will be applied without editing the code, making this easy for the administrators (so they will not call me for "hey! We want to add this condition, blah blah blah) and they can do it by their own.

PHP Code:
// Imagine there's a code here..

// The custom conditions will be placed here
$custom_conds $this->db->get('upload_rules');

if(
$custom_conds->num_rows() > 0)
{
    
$the_rules $custom_conds->result_array();

    foreach(
$the_rules as $key => $rule_set)
    {
        
// Convert pattern into a PHP conditional statement
    
}


And then maybe the rules in the database will look like this

Code:
[rid]     [rule_order]     [rule_pattern]
1         1                fieldname|contains|keyword|callback

// Where pattern is separated by pipe
// Or maybe I can use JSON format for easy organization of condition (because maybe in the future
// I create a condition with if-else if-else

Something like that? Then the order will be based on the order inside the database.
The reason I want to do that is to make the app flexible so any admins can do that. I know this is risky but maybe there's an alternative.

Hope you get my point now. Smile  Big Grin
Reply

#4
Got it.

Depends what you specifically meant by "is it safe", but there are no technical reasons you shouldn't consider keeping some rules in DB and filter through uploads based on that.

Some setting pages could get complicated and take long time to implement, but my golden rule is - would it take too long to deploy manual logic changes and/or would I be annoyed if I had to always change the logic on code side? If the answer is YES to either, I build settings page that other employees can use to adjust application behavior Big Grin
Reply

#5
(07-11-2018, 06:29 AM)Pertti Wrote: Got it.

Depends what you specifically meant by "is it safe", but there are no technical reasons you shouldn't consider keeping some rules in DB and filter through uploads based on that.

Some setting pages could get complicated and take long time to implement, but my golden rule is - would it take too long to deploy manual logic changes and/or would I be annoyed if I had to always change the logic on code side? If the answer is YES to either, I build settings page that other employees can use to adjust application behavior Big Grin

My answer is YES.
Could you give me some ideas/example on the "I build settings page that other employees can use to adjust application behavior"? Hahahah.
Pleeeease. Thank you.
Reply

#6
(07-11-2018, 08:41 AM)kaitenz Wrote: Could you give me some ideas/example on the "I build settings page that other employees can use to adjust application behavior"?

It really comes down to the project you are working on.

Our business needs are not that complicated, so we don't have to implement filtering like you were describing.

I'd say start from figuring out what the business needs might be. Building a complete condition engine takes time, but also, it would put pressure on admins to use it the right way, to the simpler it is designed to be, the easier it is use and build.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.