Using PHP more efficiently???
Posted: Mon Mar 08, 2010 11:34 pm
I am currently writing code from scratch every time. What I'm looking for is a faster and more efficient way of writing PHP code, something I can reuse. I know I can write my own classes but classes isn't one of my strong points. I'm still struggling on understand it, besides plenty of people have created and shared classes - but can't seem to find one that does all that I need. So what do I need?
A way to query the database. Every time I do a SELECT statement, I have to do 3 things every time.
- check if the SQL ran okay and display if an error has occurred
- check if records exists and display them
- if records don't exists, display message
Every time I do an INSERT statement, the following has to occur.
- check to make sure no duplicates are made
Every time I do an UPDATE statement, the following has to occur.
- check to make sure no duplicates are made
Every time I do a DELETE statement, the following has to occur.
- do not allow a record to be deleted if it will create orphan records on other tables
I have the database covered using foreign key constraints and other things.
I'm looking for a simpler way to paginate recordsets.
An easier way to handle authorization and authentication. I've created some functions to handle this and it seems to work out okay but I'm always looking for improvements or more efficient ways.
An easier way to implement layouts.
What I've tried...
- Dreamweaver: At first, it's a good solution but projects become more complicated so I end up having to write code by hand. Plus, DW code is ugly, long and inefficient.
- PEAR DB/MDB2: I tried to use this but documentation is little so I end up getting stuck.
- Include files: Very helpful for my layout problems but doesn't address the amount of repetitive code that handles database queries.
- Ruby on Rails: I started to use Rails and love it... until I get to the authentication/authorization part. The community can't seem to agree on what the best method/solution is. Another downside is the learning curve. I have to spend time learning things but once I get used to it, a lot of things can be automated. Also uses MVC which I'm still a noob with.
Things I'm about to try...
- PHP Adodb: This looks like a good database abstraction layer. Only thing I'm concerned about is it seems there hasn't been much activity in terms of making improvements and fixes.
- Smarty template: It looks good as well but will probably have to continue doing include files for different areas of the page layout. Should speed up development though - at least it looks like it will.
- CakePHP: Since I started to read about Rails, I'm starting to understand more about MVC architecture. But is this way too much for what I'm looking for?
So there you have it. My dilemma. I wasn't sure where I should post this since it seems to fit in more than one forum category. Hope this is the right place. I welcome any suggestions. Thanks for you time.
A way to query the database. Every time I do a SELECT statement, I have to do 3 things every time.
- check if the SQL ran okay and display if an error has occurred
- check if records exists and display them
- if records don't exists, display message
Every time I do an INSERT statement, the following has to occur.
- check to make sure no duplicates are made
Every time I do an UPDATE statement, the following has to occur.
- check to make sure no duplicates are made
Every time I do a DELETE statement, the following has to occur.
- do not allow a record to be deleted if it will create orphan records on other tables
I have the database covered using foreign key constraints and other things.
I'm looking for a simpler way to paginate recordsets.
An easier way to handle authorization and authentication. I've created some functions to handle this and it seems to work out okay but I'm always looking for improvements or more efficient ways.
An easier way to implement layouts.
What I've tried...
- Dreamweaver: At first, it's a good solution but projects become more complicated so I end up having to write code by hand. Plus, DW code is ugly, long and inefficient.
- PEAR DB/MDB2: I tried to use this but documentation is little so I end up getting stuck.
- Include files: Very helpful for my layout problems but doesn't address the amount of repetitive code that handles database queries.
- Ruby on Rails: I started to use Rails and love it... until I get to the authentication/authorization part. The community can't seem to agree on what the best method/solution is. Another downside is the learning curve. I have to spend time learning things but once I get used to it, a lot of things can be automated. Also uses MVC which I'm still a noob with.
Things I'm about to try...
- PHP Adodb: This looks like a good database abstraction layer. Only thing I'm concerned about is it seems there hasn't been much activity in terms of making improvements and fixes.
- Smarty template: It looks good as well but will probably have to continue doing include files for different areas of the page layout. Should speed up development though - at least it looks like it will.
- CakePHP: Since I started to read about Rails, I'm starting to understand more about MVC architecture. But is this way too much for what I'm looking for?
So there you have it. My dilemma. I wasn't sure where I should post this since it seems to fit in more than one forum category. Hope this is the right place. I welcome any suggestions. Thanks for you time.