Home News Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | Any php coders out there?


You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Computers & IT > Internet Discussion

Any php coders out there?
Reply
 
Thread Tools
Old 08-12-2009, 13:37   #31
handyman
bah
 
handyman's Avatar
 
Join Date: Jun 2003
Location: Nr Carnforth
Age: 36
Services: M6 Keele
Posts: 5,455
handyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny star
handyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny star
Send a message via MSN to handyman
Re: Any php coders out there?

in my basic test I had customer, event, event dates and a master table for bookings onto dates. For event I had a separate page to do the following add/added/update/updated/delete/deleted plus an index page to list all events.
handyman is offline   Reply With Quote
Old 08-12-2009, 14:30   #32
Damien
Cable Forum Team
 
Damien's Avatar
 
Join Date: Mar 2004
Age: 25
Posts: 16,129
Damien has a pair of shiny starsDamien has a pair of shiny starsDamien has a pair of shiny starsDamien has a pair of shiny starsDamien has a pair of shiny stars
Damien has a pair of shiny starsDamien has a pair of shiny stars
Re: Any php coders out there?

I wouldn't have each different type of operation in their own file. Events could hold all the code. Maybe spilt the files into database operations (save/delete/get/update etc) and another for any logic.
Damien is online now   Reply With Quote
Old 08-12-2009, 15:14   #33
handyman
bah
 
handyman's Avatar
 
Join Date: Jun 2003
Location: Nr Carnforth
Age: 36
Services: M6 Keele
Posts: 5,455
handyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny star
handyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny star
Send a message via MSN to handyman
Re: Any php coders out there?

I'll give that a bash with my lil 4 table tester and see how I get on. Thanks
handyman is offline   Reply With Quote
Old 08-12-2009, 15:19   #34
Damien
Cable Forum Team
 
Damien's Avatar
 
Join Date: Mar 2004
Age: 25
Posts: 16,129
Damien has a pair of shiny starsDamien has a pair of shiny starsDamien has a pair of shiny starsDamien has a pair of shiny starsDamien has a pair of shiny stars
Damien has a pair of shiny starsDamien has a pair of shiny stars
Re: Any php coders out there?

My last post may not have been clear. I mean all database operations for a given 'thing' reside in one file. (it is possible a 'thing' spans multiple tables. Like Events and Event Locations will likely be different tables but the responsibility of a Event file. In that case it makes sense to have one file but more than one table).
Damien is online now   Reply With Quote
Old 08-12-2009, 15:35   #35
handyman
bah
 
handyman's Avatar
 
Join Date: Jun 2003
Location: Nr Carnforth
Age: 36
Services: M6 Keele
Posts: 5,455
handyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny star
handyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny star
Send a message via MSN to handyman
Re: Any php coders out there?

You are likely very clear however I am still learning so still confused.

For the customer table I have and index.php file that extracts all of the customer data and displays this as a table. At the top I have a link to add a new customer and at the end of each customer record I have a link to delete or update. If I add a delegate this goes to add.php which is a form to capture the details which then sends this to added.php which performs the database addition. Similar for update/ updated. Delete.php is a 'are you sure' page which then sends the user to deleted.php on clicking 'yes' and deletes the row. This is repeated with the other tables.

I will PM you a link to what I have created so far. This is just my first attempt at working with relational tables so probably doing this all wrong. Hey it works though :-)
handyman is offline   Reply With Quote
Old 08-12-2009, 23:02   #36
Damien
Cable Forum Team
 
Damien's Avatar
 
Join Date: Mar 2004
Age: 25
Posts: 16,129
Damien has a pair of shiny starsDamien has a pair of shiny starsDamien has a pair of shiny starsDamien has a pair of shiny starsDamien has a pair of shiny stars
Damien has a pair of shiny starsDamien has a pair of shiny stars
Re: Any php coders out there?

Yes. I see what you mean now. My points were referring more to code you store in makeshift classes and then call when needs be. I don't think having a file for each operation is a good idea. Instead you should be calling the methods (delete and so on) but they should reside in a smaller number of files than the url suggests.

I am not a PHP programmer so cannot really help you with that. I suggest you look at MVC frameworks for PHP or drop Punky a PM and ask him. I use .Net and related technologies and have code/systems which means a single class handles a lot of requests.

So if you were to go: somesite.com/products/edit/1

products would be the file
edit would be the method
1 would be a argument.

If you plan to make this quite large I suggest you go down the MVC path or ask Punky how PHP programmers deal with stuff like that
Damien is online now   Reply With Quote
Old 09-12-2009, 10:14   #37
Graham M
 
Graham M's Avatar
 
Join Date: Jul 2003
Location: Poole, Dorset
Age: 26
Services: Sky+ V-Box VM 10MBit
Posts: 12,823
Graham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny star
Graham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny starGraham M has a nice shiny star
Send a message via MSN to Graham M Send a message via Yahoo to Graham M
Re: Any php coders out there?

Frankly, do it how you want it, if it keeps the code neat and tidy, do it the way you've been doing it. The only thing I will say is make sure the pages that don't need to be called separately can't be called separately, IE check they are referenced from the place they're meant to be or that the correct input data has been given rather than just making assumptions in your code - or you could end up in a world of pain later on.

Hope this helps
__________________
Desktop: Intel i7 SandyBridge 2600k 3.4GHz @ 4.7GHz - 8GB DDR3 - ATI Radeon HD 5770 1GB - OCZ Agility 3 60GB SSD Laptop: Dell Studio 15 - Intel i3 M350 @ 2.27GHz - 3GB DDR3 - ATI Radeon Mobility 4570
Graham M is online now   Reply With Quote
Old 09-12-2009, 10:44   #38
punky
Gone
Alpha Bravo Charlie Champion
 
Join Date: Jun 2003
Age: 30
Posts: 14,760
punky has a golden aurapunky has a golden aura
punky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aura
Re: Any php coders out there?

Quote:
Originally Posted by Damien View Post
If you plan to make this quite large I suggest you go down the MVC path or ask Punky how PHP programmers deal with stuff like that
There are some MVC libraries for PHP including ZendFramework, CakePHP or CodeIgnitor. I think that would cause more problems than it would solve though. MVC programming isn't completely straightforward, especially for novices. Although for ZendFramework in particular (haven't used the other two) it does do a lot of the grunt work for you by abstracting DB access etc.

As for the thread, just go with what's logical and you can manage easy. Worry about coding within certain patterns when you are part of a coding team at a company.

Quite often when people ask for coding help the code they've put is really badly structured but i've learnt its easier in the long run to try and tweak it to work rather than completely restructuring it into how I or most others would do it.
punky is offline   Reply With Quote
Old 09-12-2009, 10:49   #39
Damien
Cable Forum Team
 
Damien's Avatar
 
Join Date: Mar 2004
Age: 25
Posts: 16,129
Damien has a pair of shiny starsDamien has a pair of shiny starsDamien has a pair of shiny starsDamien has a pair of shiny starsDamien has a pair of shiny stars
Damien has a pair of shiny starsDamien has a pair of shiny stars
Re: Any php coders out there?

Quote:
Originally Posted by punky View Post
There are some MVC libraries for PHP including ZendFramework, CakePHP or CodeIgnitor. I think that would cause more problems than it would solve though. MVC programming isn't completely straightforward, especially for novices. Although for ZendFramework in particular (haven't used the other two) it does do a lot of the grunt work for you by abstracting DB access etc.

As for the thread, just go with what's logical and you can manage easy. Worry about coding within certain patterns when you are part of a coding team at a company.

Quite often when people ask for coding help the code they've put is really badly structured but i've learnt its easier in the long run to try and tweak it to work rather than completely restructuring it into how I or most others would do it.
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.
Damien is online now   Reply With Quote
Old 09-12-2009, 10:58   #40
punky
Gone
Alpha Bravo Charlie Champion
 
Join Date: Jun 2003
Age: 30
Posts: 14,760
punky has a golden aurapunky has a golden aura
punky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aura
Re: Any php coders out there?

Quote:
Originally Posted by Damien View Post
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.
punky is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Google Search




All times are GMT +1. The time now is 17:44.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Copyright © 2003 - 2012, Cable Forum.
(server1.cableforum.co.uk)

SEO by vBSEO 3.3.2