Is there a simple way to write a common function for each of the CRUD (create, retreive, update, delete)
operations in PHP
WITHOUT using any framework. For example I wish to have a single create function that takes the table name and field names as parameters and inserts data into a mySQL database
. Another requirement is that the function should be able to support joins I.e. it should be able to insert data into multiple tables if required.
I know that these tasks could be done by using a framework but because of various reasons - too lengthy to explain here - I cannot use them.
If you try to write such function you'll soon discover that you've just realized yet another framework.
Of course not, that's why those frameworks exist and implement crud facilities. I'd first try to convince whomever it takes to actually use an existing framework and second, failing the above, I'd take a look at one or two of them and copy the implementation ideas. Failing all that you could take a look at http://www.phpobjectgenerator.com/
Without any frameworks includes without any ORMs? Otherwise I would suggest to have a look at Doctrine or Propel.
I know the way you feel.
Pork.DbObject is a simple class that you can extend your objects from. It just needs a db connection class to work.
please check out: www.schizofreend.nl/pork.dbobject/
(oh yeah, yuk @ php object generator. bloat alert! who wants to have those custom functions in every class???)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With