Quote:
Originally Posted by Damien
How would you suggest avoiding having a Php file for every possible operation? Seems messy too have a file for each update/delete and so on.
|
Well Apache doesn't care and if HM understands it fine then it doesn't really matter.
I've done a variety of patterns, it depends on the project. One idea is to perform a switch on the query string.
/events.php?do=add
/events.php?do=edit&id=55
then:
PHP Code:
switch($_GET['do'])
{
case 'add': performAdd();
break;
case 'delete': performDelete($_GET['id'])
break;
default:
//invalid operation
break;
}
}
Seomtimes you split it up per database or table/model (like in MVC). Sometimes you split it up by operation. If you have a lot of operations you can split it up logically byu directory. It depends on experience and the project.