SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 27

Thread: OOP observation

  1. #1
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    OOP observation

    Ok you OOPs folks, I have been trying to learn a little oop. Now I'm totally confused. I've read post about oop vs. procedural and I conclude the following: Why do you like adding several thousand lines of code to programs? From what I see, even if you do a program using OOP (fine), underneath this you still somewhere have the basic raw "regular" php code, ie., the lines to open a database, the lines of code to loop through records, if/else statements, and that sort of stuff.
    So, isn't OOP just a way to call (have run) repetitive procedural "regular", root, to the basic php routines. Every OOP example I googled has this root, basic PHP at it's core.
    Now if that's true, which it is "without a doubt", what's the difference of using OOP to make things easier vs doing a copy and paste of a page of code that opens a table, and has edit/view/update ability, and taking this page of code and changing just a few things like connection and field names, etc?
    I just don't see why This OOP is talked up so much when behind all OOP is the core basic language thats being called. I see what OOP is now, mostly reusable, like a connection/query fed parameters instead of coding it each time.
    The point is it's still coded once with the ability to receive parameters, therefore regular "to the core/basic php is at the root. Do most of you just want to cut down on the number of .php files it takes to do something? I'd like to have one of you look at a complex program and let me know if it's possible in OOP. It uses php and css and javascript, and can handle paging with complex lookups. I can't see how this can be done using OOP, if I can understand this I could then learn OOP better. I can upload screen shots if someone is willing to eval it, reply and let me know.

  2. #2
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The key to OOP is not just the way in which code is organised, but the way in which your code is designed. Take the following example (I'm using Ruby as my PHP is a little rusty, sorry), which could be considered "procedural" OOP (that is a deliberate oxymoron):

    Code:
    employees = company.employees
    employees.add(new_employee)
    The above code breaks encapsulation - one of the core OO principles. You are asking the company for some information (its employees) and then you are manipulating it. What you should be doing is moving the responsibility for adding employees to the object that knows about them (the company):

    Code:
    company.add_employee(new_employee)
    This is the principle of "Tell, don't ask".

    Obviously you have to resort to basic PHP at some level - it is the building blocks on which you design your OO code.

  3. #3
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To an OOP PHP programmer: How about a little challenge. Let me upload some jpegs of screen shots of a complex database, and I'd like to see if anyone has a clue as how to duplicate it in OOP. If someone thinks they can do it in OOP, I'll share my source code. I'd just like to see one solid example of a database in OOP with linked tables / complex "lookups" / etc.
    If you use fedex, their dropdown to select a receiver is a good example, but one main difference, a way to filter the dropdown so 525000 records aren't in dropdown. I filter mine so if you want all occurences of "wh" only, you can. I have googled, sitepointed, yahooed, and am yet to see a "complete", complex, from start to finish example of an OOP database. Not code segments, not a simple flatfile database that a 6th grader could do, but something that a large shipping, transportation, warehousing, or other company could really use in the real world.
    I'd like to learn OOP (only if that's the way things are going, and I have no choice), but where are the examples? To repeat complete examples, including any forms, html, php, (ground up) from start to finish. Most examples I've seen have nothing to do with a real world database. It's as though there is a missing link from regular php to OOP. In the examples on the web, where are the forms a user fills out?
    Where is an example of (not just paging), but paging while the recordset is filtered, and you need to pass the page and filtered condition along, then after an edit return to page and filter condition you left off on. I have a sneak feeling no one can answer these questions, I think that most OOP is flat file simple databases. But please prove me wrong. I beg, plead for a real example, not non-sense.

  4. #4
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Pittsburgh, Los Angeles
    Posts
    706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just don't see why This OOP is talked up so much when behind all OOP is the core basic language thats being called. I see what OOP is now, mostly reusable, like a connection/query fed parameters instead of coding it each time.
    You should be careful to not confuse issues that face OOP in PHP and OOP in general. But regardless people talk up OOP just like people talk up their religions, in either case I don't think there is any real logic to it. The fact is that OO, procedural, functional etc languages all have domains they do well in, each give you a different way to look at a problem. But in each case the same issues apply: encapsulation, reuse, managability. For me the front-end of web applications make most sense from a procedural point of view where as the backend is usually best thought of with OOP. Unfortunately PHP support for both procedural and OOP is lacking, but I've always thought its odd that people picked a langauge that is procedural at its heart to do OOP (after all there are so many real OOP languages available).

    Anyhow, if you aren't having any issues with your current style of coding then there is no sense in changing it. But, if for example you once you are having management issues etc, then it may be time to change matters.

  5. #5
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This was on php forum, but they moved it.

  6. #6
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ha ha, I didn't think there would be any takers. I guess I will need to track down the knowledgeable folks that programmed the fedex site. Mean while the php oppers will continue to do cute little flat file guest books.

  7. #7
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Pittsburgh, Los Angeles
    Posts
    706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ha ha, I didn't think there would be any takers.
    It would've helped if what you asked was coherent....and even if it was nobody is going to waste their time trying to prove something to you.

  8. #8
    SitePoint Guru
    Join Date
    Nov 2002
    Posts
    841
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OOP versus Copy & Paste?

    Answering for the benefit of anyone unlucky enough to stumble into this thread...

    If you use OOP to eliminate duplicate code, then when you have to make a change to your program, ideally, you need only make it in one place one time.

    If you've copy/pasted all over the place, then you have to go back and make the change in many places. That process is slow, error prone, and tends not to get done.

  9. #9
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still not the question. I am looking for a COMPLETE OOP database example that's realistic. One like the fedex site I mentioned above with everything included, including the forms for input. The examples I have seen shows all this OOP non-sense, but not how the user interacts with the database. It's as though the examples are assuming you know how to apply oop to a database already. You don't take a child and go from "how to add" to "How to solve calculus equations" over night. How does the oop thing interact with the forms to enter data and that type of thing. Gees how much more detailed can I be? Was the paging with the passing of the mentioned variables not clear. Was the filtered drop down not crystal clear? What part of a realistic real world example do people not understand? Any real large industry database needs at least the above mentioned. You do not want to do a lookup and have 5 million records in a dropdown.

  10. #10
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And, please, please don't say google suggest, this is cute, but not the same. Come on now you real programmers know it's not the same as a filtered dropdown used for field lookups, (like the fedex fills fields for receiver). Only someone totally without clue would bring up the google suggest thing. There has got to be an x- visual foxpro or visual dbase programmer out there who is programming in php who has a clue of what I mean by lookups. Apparently most oop folks don't understand or grasp auto filling fields. But in real large real world databases, it's a must.

  11. #11
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,625
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I think you are missing the point of using higher-order design patterns in applications. It is not about one form, or one datagrid. It is about making an understandable and more easily maintainable codebase. One that can accept changes without breaking everything. Remember, the biggest cost in coding most projects is not the initial build but the continuing maintenence.

    In a well-designed, OO application, the front end should not care a lick how the business layer is actually getting the data objects. It just requests them using the public API provided. If your application must handle the paging and filtering, this api needs the requisite methods to return paged and/or filtered records.

    I am not going to go and write your example for you. But I can tell you that I could do it in .NET--a fully object oriented environment--without writing more than a dozen lines of back-end code. If I need to actually write any at all.

    I think PHP is probably the worst thing to attempt to learn OOP in. It is truly procedural at heart and loose typing is a liability. I would try using something like Java or C# myself. But Ruby and Python are valid choices if you wish to stay dynamically typed.

  12. #12
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jim9, you have no idea what you're talking about. You have mixed three completely different concepts -- databases, object-oriented programming (server side, specifically PHP) and "ajax" (Google Suggest) -- and talk them as they are somehow the same or parts of the same thing.

    Can you please describe what do you have in mind when you say OOP?

  13. #13
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since you mentioned .net, I have a question: At one time I was learning asp. Then from what I saw on the web, it seemed asp was dying out, and being replaced by .net (aspx). Then i began to see php all over the place. I did searches, and found most servers in the world including the U.S. run apache/php. The confusion comes in as to what web database frontend to learn? By frontend, I'm referring to asp.net / asp / java / php, etc. Naturally the backends being Microsoft SQL Server / Mysql / Oracle / DB2, etc. Backend is where the actual database tables reside. The real funny thing is I can use visual foxpro or ms access with an odbc connection right now and connect to any of the backends and have a nice frontend interface. But, that doesn't teach me anything about an internet/intranet database. I can right now bang out a frontend (yes like the fedex dropdown), but adding a textbox so user can filter results
    using what I call normal looking php in just 4 or 5 php files:
    Code fragment of normal non oop looking php.
    <?php

    include 'library/config.php';
    include 'library/opendb.php';
    set_magic_quotes_runtime(0);
    if (isset($_POST['t1'])) {
    $t1 = $_POST['t1'];
    }
    else {
    $t1 = $_GET['t1'];
    }
    // how many rows to show per page
    $rowsPerPage = 5;

    // by default we show first page
    $pageNum = 1;

    // if $_GET['page'] defined, use it as page number
    if(isset($_GET['page']))
    {
    $pageNum = $_GET['page'];
    $page = $_GET['page'];
    }
    else
    {
    $pageNum = 1;
    $page = 1;
    }
    // counting the offset
    $offset = ($pageNum - 1) * $rowsPerPage;

    $query = "SELECT petid, petname, species, sex, ownerid, petowner, ostreet, dogpic";
    $query = $query . " FROM pets";
    $query = $query . " WHERE petname Like '".addslashes("$t1%")."'";
    $query = $query . " ORDER BY petname asc ";

    $pagingQuery = "LIMIT $offset, $rowsPerPage";
    $result = mysql_query($query . $pagingQuery) or die('Error, query failed');
    echo "<div id=tbl-container>";
    echo "<table border=1 id=tbl style=behavior:url(move-lock-col.htc)>";
    echo "<thead>";
    echo "<tr>";
    echo "<th>PET ID</th>";
    echo "<th>PET NAME</th>";
    echo "<th>SPECIES</th>";
    echo "<th>SEX</th>";
    echo "<th>OWNER ID</th>";
    echo "<th>PET OWNER</th>";
    echo "<th>STREET</th>";
    echo "<th>PIC</th>";
    echo "<th>EDIT</th>";
    echo "<th>VIEW</th>";
    // more ............
    Ok, is there an example on the web where I can see an asp.net web database that's complex with paging, lookups with auto filled fields? The fedex example would be "the example" if their dropdown had a choice for a filter first. Let's say with no filter their would be 500,000 customers in dropdown. Futhermore, let's pretend you only want to lookup all occurences of "DA". Examples: david truck lines, davis cargo, davey logistics, etc. Ok with the filter you only get names that begin with DA. You have to admit one thing, most web programmers must not know how to handle this complex stuff, otherwise you see an example somewhere. Bear in mind, this is not an initial search (like when you can search for a record to edit), but you already have the record up and editing it and you might have a ship to field, and address, contact, phone, and other fields need to be filled automatically. I actually believe most web programmers get confused here, and don't understand a lookup.
    My whole original question was can this be done in OOP php. I never asked someone to write code for me, I just want to see an example. If there are no examples, then it probably can't be done. If you take a close look at Dbase, visualfoxpro, ms access, alpha5, and other desktop / network databases, that's the ONE MAIN ADVANTAGE of using them. dbase had a browse mode, so you could filter first and go into browse mode to select a record, and from that record that's linked to the current record fill fields. I first programmed in dbase 3+. At one time in the world this reinged king of databases, both small and industrial. It's as though you have web database programmers that don't have a clue how to deal with linked tables and table lookups. Yes they can program a little flat file thing, but the second it gets complex, ouch.
    You mentioned form and datagrid. I do not know how to tie a form or datagrid to oop. Good grief, that what I begging for help with. All example I see jump right to oop. Where are the steps that take someone from regular php to oop php. A chapter has been left out. I now know how to pass a page and filter condition around so as to return where I left off in regular php, but where is an example of doing that same sort of thing in oop. You might say that i need to transform more complex stuff to oop, and there is no guidance on how to do this sort of thing. However, if all I was doing was migrating a simple flat file database over to oop, then I can find examples of this. So why do you think I started to believe it couldn't be done in oop, because of the lack of examples.

  14. #14
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To other reply, you cannot talk about a large industrial database without auto filled fields. In another forum someone referred me to google suggest. Not the same thing. Look at the my post before this one. I want to learn how to take a complex frontend to a mysql database and convert it to oop, but all steps. See the line concerning paging with passing page and filter condition. I DO NOT have a clue as to how to convert something this complex to oop.

  15. #15
    SitePoint Addict
    Join Date
    Mar 2004
    Location
    Grand Junction, CO
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Of course I don't have any real clue what you're talking about...however, I wrote www.pregopoker.com using Ruby on Rails - Ruby being an OOP language. There are lots of classes and objects doing lots of cool things, and the cool things don't care about the database.

    I highly recommend taking a look at the book Domain Driven Design (or any book on app design, for that matter). The best approach, for me, is a layered architecture. Your application will need to do a number of things. The most important, unique part of course is business logic. But of course there is infrastructure stuff like interacting with databases, sending mail, etc. The key is to make your business logic unaware of the underlying infrastructure. It's the same concept as when you call "SELECT * FROM my_table WHERE id=other_table.some_foreign_key" - you don't care about the underlying mathematical concepts and process, only that you get the result you want. OOP lets you easily keep the different parts of your application separate from each other.

  16. #16
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,625
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac
    Jim9, you have no idea what you're talking about. You have mixed three completely different concepts -- databases, object-oriented programming (server side, specifically PHP) and "ajax" (Google Suggest) -- and talk them as they are somehow the same or parts of the same thing.

    Can you please describe what do you have in mind when you say OOP?
    Good summary. I think part of the reason that you are having trouble finding the example you need is that you are asking for something very wide ranging. In order to be properly structured, something like this would involve more than a dozen objects wrapping different tasks.

    Oh, and it does not really matter how many servers run what. It matters what your server/your employer's servers run.

  17. #17
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, jim9, but it seems to me that you have trouble grasping the concept of Web applications. Forget about OOP for the moment, go back and learn about HTTP and HTML first; keep in mind that what you execute on the server only outputs a set of instructions (HTML) for the client (browser) to display.

    Web is much more complex environment than your traditional desktop app builder like Access; you effectively create two separate applications, especially if you want your GUI to go beyond the basic HTML forms, which are very primitive compared to a rich GUI environment.

    Everything you talk about can and has often been done in OOP -- but this is something completely different than what you're used to. For example, there are no simple controls for a filtered list you keep asking for -- especially in PHP, there is not even a common display layer apart from the simplest echo statement; you have to build that yourself.

    The example you're asking for has several different layers; here's how it might look like in an application of mine (simplified):

    PHP Code:
    $view = new FilteredListView();
    $model = new WidgetsCollection();
    $model->retrieve("color = 'blue'");
    $view->widgets $model;
    echo 
    $view->render(); 
    Does this help?

  18. #18
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ok some pics








    Image1 is a simple search box to filter the records, here only records that start with "b".
    image 2 is the page to scroll through and page through result set. Also you can pick a record to view or edit.
    image 3 is a record you chose to edit. Notice the search for owner text box. This is main idea of my post. Notice I entered a j, knowing owner starts with j.
    image 4 is filtered dropdown with only names that start with j.
    image 5, you chose a name and record is updated.
    image 6 is edit page showing updated record. All owner stuff in updated automatically when an owner is chosen from the dropdown.
    BUT, and this is important, you can use dropdown, or enter a temp value. Why is this important. In a trucking company when dealing with lookups, some shippers are your customer. Therefore you want all their information address, phone, contact person, etc looked up. Whereas, if you are doing a brokered backhaul load, this isn't your customer where the driver will be loading, you don't need all fields filled. The driver will call the broker for that information. Yes the real database is trucking, this example is pets just for testing of lookups. The idea is exactly the same. So dependant dropdowns is not an option.
    At bottom of return page after an update, it shows http://server/pets.php?page=2&t1=b. I couln't capture this on a screen image. t1 is orginal search string.
    I can program this now, today. I am trying to learn what the "WHOLE THING" would look like in oop php. Not little code snipplets, but all, including forms, the lookup dropdown, all.

  19. #19
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    P.S. Top row and left 2 columns in image 2 is froze for scrolling. I would want to learn this also in oop php. And the underlined link isn't a link, it's on localhost right now.

  20. #20
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Double P.S. You put in some code.
    Code:
    $view = new FilteredListView(); 
    $model = new WidgetsCollection(); 
    $model->retrieve("color = 'blue'"); 
    $view->widgets = $model; 
    echo $view->render();
    $view = new FilteredListView(); this line of code doesn't explain to someone trying to learn. I am talking about a complete application, ALL / everything, server side, and all client side stuff. You see I do not understand how client side forms and server side oop php tie together. I do however understand how client side and server side fit togeher in normal php programming. I admit, I am dumb to oop php. It's the code snipplets that confuse me. You might as well write Z@*12_44UUU#. I could write a simple html input form right now but I would not have a clue as how to tie it to a server side oop php thing. But the same form with regular php using standard POST and GET techniques, and update and or insert statements I can grasp.

  21. #21
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,625
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Ok. Well, rather than starting with a rather complex problem, you might want to start with a simpler issue than a complete, functioning web application. I would also advise taking a class, possibly in a fully OOP language such as java or .NET. OOP is a bit tough to get your head around, then one day it just clicks and you wonder how you did anything differently.

  22. #22
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jim9
    You see I do not understand how client side forms and server side oop php tie together.
    Exactly, that's my whole point.

    Quote Originally Posted by jim9
    I do however understand how client side and server side fit togeher in normal php programming. I admit, I am dumb to oop php. It's the code snipplets that confuse me. You might as well write Z@*12_44UUU#. I could write a simple html input form right now but I would not have a clue as how to tie it to a server side oop php thing. But the same form with regular php using standard POST and GET techniques, and update and or insert statements I can grasp.
    It's exactly the same, OOP or not. The whole point of OOP is to organize the code in such a way that you don't have to copy/paste the same code (PHP or HTML) over and over again.

    You see, the only fundamental difference between OOP and procedural programming, at least in PHP, is in code organization. For example in "normal PHP programming", as you call it, you might put commonly used code inside a function; OOP encapsulates functions within another level of abstraction, which gives another level of complexity on a large scale, but makes things simpler to maintain on a smaller scale.

    In my code example above, each "new Something()" line creates another object, and other lines invoke functions available on those objects. For example, I have defined the FilteredListView, which basicaly spits out the HTML for an appropriate form element, in one place only, but I can reuse it each time I neeed another filtered list. Similarly, my WidgetsCollection takes care about retrieving widgets from the database, and I can give it a filter (in this case color = 'blue', which is something you would insert into a SELECT statement) to narrow the query. That way I don't have to write the SELECT statement for widgets all over again -- it's defined in one place only, namely the WidgetsCollection class.

    One caveat: one thing where PHP OOP differs significantly from other OOP languages is that in those others, once you create an object it essentially remains in memory until it gets destroyed, and you can reuse the same objects in each page request. In PHP everything lasts as long as a request lasts; once your page finishes loading, nothing exists anymore, and you have to recreate it on next request. This has both benefits and disadvantages, which I won't go further into.

  23. #23
    SitePoint Evangelist
    Join Date
    Apr 2003
    Location
    Chicago, USA
    Posts
    417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Once you go OOP, you will never go back to procedural. You will see why when you understand OOP better.

    But I do think that some things, like very simple and small PHP applications do not need an OOP design. But for medium to large scale projects, it would be suicide not to incorporate some OOP design.

  24. #24
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    re: FilteredListView

    FilteredListView, which basicaly spits out the HTML for an appropriate form element
    Ok you mention this. That's what I mean where is this form, what would it look like, and how to call it?

    How about a very small example: say I have the simplest input form to add one name to a database.
    Code:
    <html>
    <head></head>
    <body>
    	<form action="add.php" method="POST">
    	<table>
    		<tr>
    			<td>Enter your name</td><td><input name="personname"/></td>
    		</tr>
    		<tr>
    			<td></td><td><input type="submit" value="submit"/></td>
    		</tr>
    	</table>
    	</form>
    </body>
    </html>
    Of course, not shown is the an auto incremnet fiels.
    Now when I hit submit:
    Code:
    <?php 
    include 'library/config.php';
    include 'library/opendb.php';
    echo "<form id=Form2 method=POST action=updated.php>";
    	error_reporting(0);
    	$vperson = ($_POST['personname']); //addslashes in case name like o'brian
    	$conn = mysql_connect("localhost", "root","sa");
    	mysql_select_db("mydb",$conn);
    $sql = "insert into testtable (personname) values ('$vperson')";
    $result = mysql_query($sql);
    $tmpid = mysql_insert_id($conn);
    echo $tmpid . "&nbsp&nbsp" . $vperson . "&nbsp&nbsp" . "added to database";
    echo "<p>record has been added click </p> <a href=\"index.html\"> here </a> to continue";
    echo "</form>";
    include 'library/close.php';
    ?>
    So above is a simple form to add a name and the php file to process that.
    The include 'library/config.php'; and include 'library/opendb.php'; are just standard connection stuff, ie:
    <?php
    $dbhost = 'localhost';
    $dbuser = 'user';
    $dbpass = 'password';
    $dbname = 'databasename';
    ?>
    I can't think of anything more simple. Now, how would a complete oop application handle this. What would all kook like?

  25. #25
    SitePoint Addict
    Join Date
    Jul 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    re: oop design

    Caldus stated
    But I do think that some things, like very simple and small PHP applications do not need an OOP design. But for medium to large scale projects, it would be suicide not to incorporate some OOP design.
    Ok do I understand you correct? I was under the impression that PHP was completely changing, like asp was dieing and the talk was asp.net. Are you saying that php will be the same but OOP is optional? Or is the day coming where OOP is the only way to use php? I guess the various post have confused me. I just need to know what to learn that might last at least a few years. If I need to switch to asp.net I guess I could. I'm not young anymore, and will get tired of having to learn a new programming language every 2 years.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •