Sergey:
I'm playing with PHPRunner now. Great stuff.
Here's an idea I had to really make it amazingly useful --
Step #1:
--------
Let the user specify an included file of PHP code. (Yes, they could write some bad code and have it not parse, but this is the risk they run.) This file would be included on every page of the PHP pages that are built.
Step #2:
--------
Using a PHP function naming convention, allow interface events to run certain functions. For instance, say that everytime a table is changed, a function named this runs:
table_change_[table name]
And the function is passed an array of the keys of the changed record.
So, if I have a table called "friends". I edit a record with an "id" of "13". This function runs:
table_change_friends(array("id" => "13"))
(Where will these functions come from? From the included file of PHP code from Step #1.)
So will the user have to write functions for every table? No. Here's the trick: this function doesn't have to exist. Using the "function_exists" function of PHP, you can check to see if the function exists or not before you call it. If it does, call it. If not, don't.
So, if I want a function to run when a certain table is changed, I write a function called "table_change_[table name]". If not, I just don't write the function (or I delete or rename it if I had already written it).
What could I do with this? ANYTHING.
Step #3:
--------
Allow complicated field-level validation using the same process. For instance, when a record is added or edited, call functions named this:
field_validate_[field name]
This function is passed the new (proposed) value for the field. So if I have a field called "credit_card_number" and it can only accept valid credit card numbers, this field is called whenever we try to write a record (add or edit) to the table:
field_validate_credit_card_number("[value to be written]")
Again, using "function_exists," you only run this function if it has been defined.
If the function passed NULL back, then the value it passed validation just fine. Move on. If if passes ANYTHING else back, then there was an error and the return value is the error message. For instance:
field_validate_credit_card_number($creditCardNumber)
{
if(strlen($creditCardNumber) != 16)
{
return "A credit card number must be 16 digits.";
}
[code to check actual validity of number]
if($invalidNumber)
{
return "This credit card number did not pass ROT13 validation.";
}
else
{
return NULL;
//You wouldn't even have to explicitly pass back NULL. Just don't pass back
anything...
}
}
You may actually want to pass this function an array of EVERY field valid. Because then I could make sure that if the "credit_card_type" field was set to "Visa," then the "credit_card_number" field began with a "4", etc.
I know this would be a big change, but imagine what you could do with it. You would get a LOT of people using it that wouldn't before because you could advertise utter and completely flexibility (which is always the concern with generated code).
Personally, I would fall deeply in love with the tool and perhaps attempt to marry it at some point. :-)
Deane