Slashdot Mirror


Build a Database Driven Site -- Quick

norburym (Mary Norbury-Glaser) writes "The third edition of Build Your Own Database Driven Website Using PHP & MySQL is written by Kevin Yank, Technical Business Director for sitepoint.com, a popular online resource for Web development. Updated for PHP 5 and MySQL 4 in this edition, Yank has put together an easy-to-follow, hands-on tutorial using the tools and techniques necessary to build a functional database-driven Web site. Many Web designers don't have deep knowledge and experience in data coding but want to get started serving up dynamic Web pages. This book gives designers and beginning coders a concise introduction to PHP and MySQL and quickly brings the reader to the page-creation stage." Read on for the rest of Norbury-Glaser's review. Build Your Own Database Driven Website Using PHP & MySQL author Kevin Yank pages 359 publisher Sitepoint rating 8 reviewer Mary Norbury-Glaser ISBN 0975240218 summary Using PHP and MySQL to Build Your First Data Driven Website

Yank starts with the basics of MySQL and PHP installation on Windows, Linux and Mac OS X systems (he notes PHP 4.3 differences as well), and walks the reader through his first PHP script (no, not "Hello World!"). This first chapter is well written, with step-by-step instructions and shell script examples. It will help even a newbie feel comfortable with the process, and encourage him or her to move on to the rest of the book.

Chapter 2 focuses on relational databases and SQL queries. This chapter is not an in-depth study of RDBMs, but rather an extremely brief overview of the concepts involved in order to introduce the reader to command line interaction with MySQL. A simple database is begun that will be used in later chapters.

Basic syntax and commands of PHP are covered in Chapter 3 (statements, variables, operators). There are a lot of simple examples here that clearly demonstrate the elemental concepts of PHP. Yank uses forms, user interaction and control structures (if-else, while loop, for loop) to illustrate some easy methods of data access and user interaction with PHP.

Chapter 4 combines the two previous chapters' concepts into the beginnings of a working data-driven Web site. Yank shows the reader how to use PHP to connect to a sample MySQL joke database ("A man walks into a bar....Ouch."). He introduces sending SQL queries with PHP (mysql_query, delete, insert, update), handling SELECT result sets and inserting data into the sample ijdb (Internet Joke) database.

Chapter 5 is devoted to relational database design, and expands the one-to-one relationship to many-to-one, one-to-many and many-to-many relationships, this chapter teaches the reader how to join data spread between tables into one resultant set. This chapter is not meant to deal comprehensively with the complexities of relational database design. Indeed, the author gives an extremely brief nod to the inherent informality of his approach and references other resources for deeper study. Yank's intention here, as with the entire book, is to use relevant real-world examples to illustrate the simpler types of relationships a beginner will experiment with and how to deal with complex data and table issues with good design practice.

The next chapter presents content management and restricted-access database administration without relying on the command line (a few hints on protecting pages with appropriate access restrictions are in the introduction to this chapter but aren't dealt with in any depth until Chapter 12). Chapter 4's mention of forms is revisited here, and forms are used to manage, add, search for, edit and delete data.

At this point, the reader will have designed a database, organized the data into categories, created Web pages to display the data to site visitors, and prepared pages for administration of the data. The HTML is separate from the data, thereby relieving the Webmaster from the onerous and constant task of having to refresh pages with content. Here, in Chapter 7, the reader learns to format and submit content without resorting to hand-written HTML by using PHP functions (Yank covers the more standardized POSIX regular expressions, not PCRE). Code examples for string replacement, boldface and italic text, paragraphs, hyperlinks and splitting text into pages are included. The last bit of this chapter is dedicated to automatic content submission and has a nice design note about creating a visible column to the joke table where newly submitted jokes are handled as a No value, which allows review by a content manager before being posted.

This leads well into Chapter 8, "MySQL Administration (backing up, access control, checking and repairing data files)." Yank explains mysqldump and the use of update logs to create a practical backup-management scheme. He also covers using the myisamchk utility to check and repair MySQL data files. Basic MySQL access control using GRANT (creates new users, assigns passwords and adds user privileges) and REVOKE (the reverse of those functions) is included in this chapter as well, along with some tips and tricks to prevent access control problems.

Chapter 9 "gets back to the fun stuff" with Advanced SQL Queries (sorting and GROUPing SELECT results, setting LIMITs, LOCKing TABLES, aliases, LEFT JOINs and Limiting results with HAVING) giving the reader a well rounded sense of the versatility and scope of SQL in general and the SELECT command in particular.

Yank veers from textual data in Chapter 10, "Binary Data" (image files, encryption keys, programs for download) and shows the reader how to deal with working with files in PHP, handling uploaded files in PHP, storing and retrieving binary data in MySQL and learning when to use semi-dynamic pages to lighten the load on server performance in the process.

Chapter 11 deals with creating persistent variables, and offers an excellent description of cookies and sessions in PHP. I like Yank's figure "the life cycle of a cookie," which shows a graphical representation of a PHP-generated cookie. Yank rounds out the chapter with a simple shopping-cart example that consists of PHP scripts handling a product catalog and a checkout page (very real world).

The final chapter of the book is titled "Structured PHP Programming," and focuses on techniques for organizing code in order to simplify management (using include files, writing your own functions and streamlining code within Web pages). Yank gives a lot of sensible advice here, and his approach is not preachy. He brings up many important pitfalls that developers fall into: too much code, difficulty of finding what you need, understanding how it works. As this is a beginner's book, I would say that good design, good technique and good sense go a long way and should be stressed at the start of anyone's career in coding.

Build Your Own Database Driven Website Using PHP & MySQL, 3rd Edition runs only about 350 pages with a clean, easy-to-read page design, comfortable typography, lots of script boxes and screen shots. The appendices cover MySQL syntax, functions and column types and PHP functions for working with MySQL. Errata can be found at sitepoint's Web site, and I can't stress enough the value of checking these out before delving into any technical or instructional book: the frustration level goes way down if you know in advance that there's a typo, or a step missing!

This is a beginner's book with the essential tools and techniques that will get anyone started with serving up their first dynamic Web site. The tutorial approach of this book makes it easy for any reader to follow the step by step instructions. Yank manages to cover pretty much every topic necessary to provide the reader with a clean overview of the topic. It's a quick read and gives the reader encouragement and enough knowledge to move on to more complex volumes on the subject. This book provides a great first step for the beginner."

You can purchase Build Your Own Database Driven Website Using PHP & MySQL from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

62 of 251 comments (clear)

  1. Do you really need a book for this? by Anonymous Coward · · Score: 2, Funny

    It's like boiling water these days.

    1. Re:Do you really need a book for this? by ArsenneLupin · · Score: 4, Funny
      It's like boiling water these days.

      And using ASP/MsSqlServer is like pouring it down your crotch. And contrarily to popular opinion, Microsoft is not McDonalds ;-)

    2. Re:Do you really need a book for this? by Anonymous Coward · · Score: 5, Funny

      > Microsoft is not McDonalds

      But they're both run by scary-looking clowns.

  2. Using PHP & MySQL to Build a Database Driven S by rackhamh · · Score: 2, Funny

    Apparently a much needed book!

  3. For the last time! by Anonymous Coward · · Score: 2, Insightful

    A summary is NOT a review.

  4. SQLlite by Philmeeh · · Score: 4, Informative

    If you really want to set up a quick database site then you may as well use SQLlite that comes bundled in PHP5. No need to worry about connecting to a separate mySQL server with all those niggling connections

    1. Re:SQLlite by odyrithm · · Score: 2, Insightful

      SQLite needs to connect to a db in the fs anyway, in much the same way as mysql, pgsql, mssql etc etc client needs a socket connection. Don't get me wrong SQLite owns your socks, but it's no easier to use than *the real* dbms's.

      --
      moo
    2. Re:SQLlite by XorNand · · Score: 3, Informative

      I tend to think along the same lines. Maybe I'm a bit of an elitist, or it's the fact that I despise contending with so many horrid DBs thrown together by people who had no clue what they were doing. I'm sorry, but these "implement technology x in minutes" books really rub me the wrong way. Why don't people take the time to learn how to properly use their choosen tools? I wouldn't expect to be able pick up a wrench today and then begin building an engine tomorrow. Designing a good relational database requires some know-how. If you want to do something fast, use a simple flat file.

      --
      Entrepreneur : (noun), French for "unemployed"
    3. Re:SQLlite by arkanes · · Score: 2, Insightful

      Eh? No. "connecting" in SQLite is managed by passing it a filename. It's orders of magnitudes simpler than installing, configuring, and connecting to a client/server RDBMs.

    4. Re:SQLlite by nofx_3 · · Score: 2, Informative

      IIRC pacman is the packages manager for Archlinux, it uses a tar.gz package much like slackware. It's quite good although I still prefer debian just for the sheer number of packages in its repository. Even compiling php and mysql from source shouldn't be too difficult for any competent linux user.

      -kaplanfx

      --
      Visualize Whirled Peas
  5. DAre I say - a waist of money! by MBraynard · · Score: 4, Insightful
    BAsed on this summary/review, this sounds like a re-write of the already free help files for PHP and MySQL. Truth is, you probably don't even need the MySQL help file as the PHP documentation covers interaction with the database pretty well and pretty much every webhost out there is running phpMyAdmin for the database management.

    And really, if you don't already have an understanding of basic DB design (tables, fields, records, data types, etc.) are you really going to be designing such a site? If you didn't, there are plenty of free resources on the web to help you do that.

    Programming is primarily a self-starter job. You learn by doing, and by using free resources out there on the web. Why pay money for a book that regurgitates already free information for two pieces of free software.

    1. Re:DAre I say - a waist of money! by anamin · · Score: 5, Insightful

      Because it's nice to have all of that information put into a single reference. When I need to look up something at a later date I'd much prefer having a book that I can quickly find the info I need, rather than digging through google, or finding out the site I book marked is no longer in existance.

    2. Re:DAre I say - a waist of money! by winkydink · · Score: 4, Insightful
      Programming is primarily a self-starter job. You learn by doing, and by using free resources out there on the web. Why pay money for a book that regurgitates already free information for two pieces of free software.

      Programming well, on the other hand....

      --

      "I'd rather be a lightning rod than a seismometer." -Ken Kesey

    3. Re:DAre I say - a waist of money! by StandardsSchmandards · · Score: 5, Funny

      Dare I say - a waist of money!

      My waist is mostly made up of fat. I would be happy if it was made of money. I could have used the money to buy a good PHP book.

    4. Re:DAre I say - a waist of money! by DrEldarion · · Score: 4, Insightful

      How many people who will be buying this book know how to do regex searches?

  6. Leans more toward the DB side by bbzzdd · · Score: 4, Informative

    As the title suggests. Nothing about PHP templating technology (like Smarty) which can lead to some pretty gnarly PHP code. I'd recommend following this book up with Advanced PHP Programming by George Schlossnagle as it focuses more on PHP.

  7. Build a Database Driven Site -- Quick by Anonymous Coward · · Score: 3, Funny

    Shouldn't that be "Quickly", or are we allowed to modify verbs with adjectives on Slashdot?

  8. Re:Using PHP & MySQL to Build a Database Drive by lucabrasi999 · · Score: 3, Funny

    "Today's Database was Driven by the Letter S and the Number 5"

  9. Coding Standards? by codesurfer · · Score: 2, Insightful

    I wish these books would include a section or two on properly coding web apps and sites. Often people who begin coding with weakly typed languages such as PHP (not a knock against it) do not become familiar with proper design and memory management.

  10. quicker to roll your own vs. pre-made by TeeJS · · Score: 2, Interesting

    I'm always amazed when books claim 'quick' web development with MySQL and PHP. I think the planning of data structures alone makes this a not quick process. With like a gazillion pre-made CMS's available for demo at OpenSourceCMS (http://www.opensourcecms.com/) wouldn't that be the 'quick' way to go?

  11. Re:Using PHP & MySQL to Build a Database Drive by SupremeTaco · · Score: 3, Funny

    I guess they ran into the 46 character bug, wh

    --
    You have a constitutionally protected right to be wrong, and I the right to ignore you.
  12. I learned my PHP using Kevin Yanks tutorials by SpaceKow · · Score: 5, Informative

    I learned PHP using Kevin Yanks tutorials and articles 4 years ago. His books and tutorials are very easy to understand and use. His tutorials and articles can be read on http://sitepoint.com/

  13. Re:Database Driven S! by emc · · Score: 5, Funny

    Remember the good old days when the /. mods would at least check the headlines before posting stories?

    No

  14. Database vs. XML Text Files by markmcb · · Score: 2, Interesting

    I recently threw together a rather Slashdot'ish site (http://www.omninerd.com/) and I used XML text files with PHP (and XSLT) over the mySQL alternative. Now, I'm no DB expert, but is there really any need for most sites to be DB driven? For example, on my site, there are articles, and the news posts that introduce these articles that readers can comment on. Perhaps I'm missing the big picture, but why would I need a DB solution when XML files get the job done, are easily portable, and can be accessed without the use of a DB program. I understand for extremely large data sets a DB is probably what you want, but what about small timers like me? Is a DB solution a waste of my time, or am I missing something big?

    --
    Mark A. McBride -- OmniNerd.com
    1. Re:Database vs. XML Text Files by prostoalex · · Score: 2, Insightful

      Two things that come to mind is search and scalability. Can you conduct quick searches through the files, and will the system scale if you become as popular as Slashdot, with thousands of daily updates (in form of user comments).

    2. Re:Database vs. XML Text Files by dreadlord76 · · Score: 2, Informative

      You are missing something.... Big...

      In a small database application, used by, let say, 500 users a month. There can easily be hundreds of thousands of records. Come end of month, you need to find 50 records out of 100,000 that meets certain criteria. How are you going to get that out of the XML text files? Read all 100,000 and then parse it?

      The fact that there may be 100000 text files out on disk should be causing all sort of alarms to go off.

    3. Re:Database vs. XML Text Files by C10H14N2 · · Score: 5, Interesting

      Indexing.

      Even on a very, very small dataset, do you want to run through n1*n2 or n1/n2 records? Very, very simple.

      Imagine: you're in the library of congress. You need not just ONE book, but *A* book with X in the title. So, what's the point of having a database? I mean, we've got all these books and all the information is like there and stuff...

    4. Re:Database vs. XML Text Files by halosfan · · Score: 2, Informative

      If you truly want to understand this, read through the first couple chapters of the Date book

      For a brief answer, your XML files (and most OO databases as an extension) might work well for your application, but try using them for a totally different application that works with the same data. That's where relational model (at least in theory) shines: it is application-agnostic.

      Additionally, as your application grows and so is the number of concurrent users, you might face issues that are just not trivial/too tedious to program by hand:

      • Transaction support. For example, you transfer $5000 from your savings account to your checking account, and the power goes down when your savings account is debited but before your checking acount is credited. If you don't explicitly code around this problem, $5000 disappears.
      • Transaction isolation. Same example as above, but instead of power outage, a program that generates your paper statement is run -- $5000 is not on the statement, even though it is in your account.
      • Durability. Same example, power goes down. Try it enough times, and depending on which filesystem your XML file is on, you may well see it corrupted when you boot the machine after power is restored.
      • Consistency/integrity. Same example, your checking account balance is stored in a two-byte unsigned integer and is currently at $63,000...

      Try Date's book for more detailed (and likely more clear) explanation.

      --
      My only problem with Microsoft is the severity of bugs in their software.
    5. Re:Database vs. XML Text Files by jc42 · · Score: 2, Informative

      Hmmm ... I wouldn't use slashdot as an example of searchable DBs. I occasionally try to find something with /.'s search thingy, hoping beyond hope, and invariably it fails me. Even if I give it a single word to find, it often returns articles that don't contain that word at all. If this is an example of mysql's search capability, I'll use something else.

      In my experience, (e)grep usually finds me a match much faster than SQL searches in whatever DB system we're using. I keep wishing this weren't true, but that's what the time(1) command tells me.

      (And google is better for finding /. articles than /. is. ;-)

      --
      Those who do study history are doomed to stand helplessly by while everyone else repeats it.
  15. The good ol' days by Tablizer · · Score: 2, Interesting

    In the early 90's many companies were working hard on data-centric products that took the grunt-work out of typical "CRUD" screens ("Create, Read, Update, Delete"). The leaders were probably PowerBuilder and Clarion, with VB and MS-Access barrowing some of the concepts to a more limited extent.

    The Web seemed to ruin this trend. CRUD screens via web forms is a pain in the glutious. Web standards were optimized for e-brochures, not business forms. Frameworks exist, but I have not found any that scale well in customization: if you need something outside of the framework, you are hosed.

    I wish the OSS community would work on producing more CRUD tools. If we have to toss HTML+DOM+JavaScript to get it, so be it. I think a remote-GUI protocol workable over HTTP is possible.

    Business development is so much smoother if you have good CRUD tools. Otherwise you spend all day reinventing the wheel and dealing with low-level annoyances. I know many slashdotters don't like dealing with CRUD issues, finding it boring or feel it lacks geek status or whatever, but there is a big business need for it. I am kind of a connoisseur of CRUD technologies (for good or bad), and the current wine is bitter.

    1. Re:The good ol' days by wackysootroom · · Score: 4, Informative

      The main problem with Clarion is that while it's easy to whip up a quick toy app, it plain dead sucks for anything more than an address book or recipe book with anything more than a couple of 1:many relations.

      Clarion was (at least from my experience with 5.0-5.5) riddled with bugs in it's QBE template and softvelocity's solution was to buy a template that fixes the problem from a third party until the next version comes out. No thanks.

      Another thing that pissed me off about clarion is that you would get buried in dialog boxes very quickly while clicking away at options with the mouse. Definetly not productive. Another fond memory I have is trying to figure out what event to use to do a certain action from the event model. The clarion community's response? Just keep trying different ones until you find one that works. I suspect that there's not one person who fully understands the event model.

      If it's CRUD you want along with maintainability and separation of business logic, view and data model. Try Ruby On Rails. You can literally develop a "toy" app 5 times faster in ROR than you could in clarion that does all of your CRUD stuff.

    2. Re:The good ol' days by Tobias+Luetke · · Score: 3, Informative
      If it's CRUD you want along with maintainability and separation of business logic, view and data model. Try Ruby On Rails. You can literally develop a "toy" app 5 times faster in ROR than you could in clarion that does all of your CRUD stuff.

      As a matter of fact I can confirm that this figure holds true for any size of application. I developed the e-commerce software powering www.snowdevil.ca 5 times faster then would have been possible without ruby on rails.

      This includes XMLRequest powered backend, inventory, order processing, credit card clearing, encryption and so on and so on and so on.

      Alone... in 3 months... while publishing an array of opensource tools and having fun doing so

  16. No mention of Security by kevin_conaway · · Score: 5, Informative

    The review didn't touch on security. I think that when you're trying to teach beginners and/or non-programmers how to build web applications, a good foundation on computer security principles is a necessity.

    Basic things like input validation and protecting against XSS are a MUST when dealing with PHP (or any language for that matter). Since beginners are the ones most likely to make these mistakes, it is important that they be educated now.

  17. How to churn out vulnerable websites! by lukewarmfusion · · Score: 4, Insightful

    1. Buy a book about how to make database-driven websites.
    2. Find the sections that tell you how to get it working.
    3. Don't read any more about it.

    Two words: "SQL Injection."

  18. Why MySQL and not PostGreSQL? (honest question!) by leoboiko · · Score: 4, Interesting

    No flames, please. I never really studied MySQL (other than installing, configuring, fiddling with Wordpress DBs, etc.), since my scholarship's teacher is a fan of PostGreSQL and I learned it first. Now I'm curious about why MySQL is so popular. Everytime someone is talking about a database-driven website it's Perl+MySQL, PHP+MySQL, Ruby+MySQL. What distinctive characteristics does it have over PostGres? Is it faster? Why do you like it so much?

    Someone said to me that it's simpler, but from the little that I tried they seemed to have pretty much the same complexity.

    --
    Prescriptive grammar:linguistics :: alchemy:chemistry. Stop being a nazi and learn some science.
  19. Mind your steps... by LuckyStarr · · Score: 3, Insightful

    1. Which language you use - be it Perl, php,
    whatever - is not important. Know the language you
    program in BEFORE you start the project! Almost
    all scripting languages have the database interfaces
    you need.

    2. Encapsulate recurring themes like database
    selects, inserts and so on. Knowing your language
    helps. Balance abstractness against usability.

    3. Use a (at least moderate flexible) template
    engine.

    Then youre (almost) done.

    In the last few years I used PHP and Perl. Both
    have their advantages and horrors. PHP is getting
    (even) better fast. Perl is quite nice if you know
    it good, which could take a little time.

    I only used MySQL and SQLite. MySQL with InnoDB is
    very reliable under heavy loads and huge datasets,
    but gets rather clumsy to back up and replicate.
    SQLite is blazingly fast, but I cannot say anything
    about reliability. I wont bet my crown-jewels on
    it (yet).

    Anyway. Good luck.

    --
    Meme of the day: I browse "Disable Sigs: Checked". So should you.
  20. Does it cover appropriateness to task? by Matey-O · · Score: 3, Interesting

    I've seen _dozens_ of live database queries to fill a 'State' dropdown on a website... ...when was the last time we ratified a new state?

    I can't help but feel a lot of 'live instant all the time' sites would be a lot more efficient if it was 4 database calls a day, rather than Every Single Time Slashdot Hits Their Site.

    --
    "Draco dormiens nunquam titillandus."
  21. Better book idea by JeffHunt · · Score: 4, Insightful

    "Build a Database Driven Site - With a Skilled Contractor Who Actually Knows What He's Doing"

    Just a thought... :)

    --

    "It was hell!" recalls former child.

  22. Watch your server go up in flames, QUICK! by C10H14N2 · · Score: 4, Interesting

    Connection pools are your friend... and rather hard to use without an app server, which kinda spoils all the fun of writing PHP, the point of which is generally being able to avoid having to use one in the first place.

    Unless you have a limitless supply of CPUs+RAM, you're going to need connection pooling very, very quickly. Frankly, they're so easy to use, I don't understand why anyone would bother coding a database app without them.

    But, for a beginner, this seems to cover some of the more important structural aspects of RDBMS in relation to webapps, not just "look, ma, it's dynamic!" Most of the books out there I've seen seem to just assume you know what you're doing on the SQL side of things and just focus on the PHP/JSP/Whatever side of things, which is just a death sentence for a beginner who has never touched a SQL server...

  23. Please don't use direct connect by just+someone · · Score: 3, Insightful

    And teach people how to abstract connection information in a separate page.

    A whole bunch of items are about to break beacuse people need to use mysqli. It would have been nicer if all these hacks used some db abstraction layer.

    And anyone who has had to update some pages a newbie built, will say please learn to abstract the connection information into a single page, not one connection per page.

    Ayeee.

  24. What PHP really needs by ShatteredDream · · Score: 3, Interesting

    Is something analogous to Web Forms. It'd be a great way to encourage people to work towards XHTML compliance if they could write some really slick UI with PHP and "PHP Web Forms" that could be manipulated directly from PHP rather than processed as a regular HTML form.

    Then again, I suppose working namespace support is probably a more pressing concern at this point.

  25. Re:Why MySQL and not PostGreSQL? (honest question! by danieljpost · · Score: 3, Informative

    I'll bite. Mysql installs & runs on Windows without any third party software. (Yes, the Web really runs on Linux. I know, I know.) PostGreSQL seems to run on Windows only in emulation (via Cygwin). Also, there used to be very slight performance differences (in terms of maximum numbers of hits to the DBMS per second, on simple benchmark datasets), and people seem to enjoy the idea that someone the same box could take 20,000+ hits in an hour using Mysql rather than 19,000 on the same hardware using PostGreSQL. This was a couple years ago so could be completely wrong now. I think there might also be a perception that MySQL is easier to use than PostGreSQL (based, I think, on pronunciation of the name). Plus, Slashdot uses MySQL. Those are the reasons I can think of. YMMV.

    --
    We must drive a sword through any hypothesis that is not strictly necessary.
  26. Re:Why MySQL and not PostGreSQL? (honest question! by JohnsonWax · · Score: 3, Informative

    mySQL is popular now because every hosting firm offers it as an option, but Postgres is far less common.

    Further, most web service add-ons (CMS, forums, etc.) are mySQL based out-of-the-box so it has become the platform on which to build.

    You'll notice there are no technical reasons there - as RDBMS go, mySQL is pretty horrible. It's the Windows of free databases, as it were.

  27. RoR is gaining traction by 5n3ak3rp1mp · · Score: 4, Informative

    Coming from some work in PHP, I've been burying my head in Ruby lately, to much joy, and have also discovered Ruby on Rails, which was also featured in a recent Slashdot article. What I've seen is amazing so far (not to mention that Ruby code is so much more readable than PHP that it's not even funny). Just an FYI...

  28. Re:Why MySQL and not PostGreSQL? (honest question! by egoots · · Score: 2, Informative

    Mysql installs & runs on Windows without any third party software. (Yes, the Web really runs on Linux. I know, I know.) PostGreSQL seems to run on Windows only in emulation (via Cygwin).

    This is no longer true! PostgreSQL 8.0 was recently released and one of the main feature enhancements is a Win32 Native Server

  29. Do the same thing with 10 Minutes work by MatthewNewberg · · Score: 3, Insightful

    Find a web host online that has PHP, MySQL and will autointall scripts for you. One such good one is http://secure.lunarpages.com/tracking/cgi-bin/clic kthru.cgi?id=mnewbe2 Purchase Webspace Login and click the Mambo installer button. Done - You Now have a PHP/ MYSQL Web Site Or you can just install Mambo yourself http://mamboserver.com/ That is my suggestion for a QUICK way to do it.

  30. Save the Adverbs, Quick! by lildogie · · Score: 2, Funny

    I suppose they're archaic now.

  31. Four Sample Chapters for this book by Anonymous Coward · · Score: 2, Informative

    The publisher is offering 4-sample chapters in PDF Format for this book on their Website: SitePoint.com/books/phpmysql1/ - It's definitely more useful in helping me make a decision than reading through a Table of Contents or Index, at least for me.

  32. Re:Why MySQL and not PostGreSQL? (honest question! by drew · · Score: 3, Informative

    i think it's mainly tradition. mysql was fast, stable, and usable for basic sites long before postgresql. mysql gained a lot of mindshare early on, when they were the only free game in town (as far as most people knew anyway). while postgresql was focused on correctness first, and speed and ease of use only later, mysql was fast and simple to get working almost from the start, and most people didn't know or care why they wanted ACID in a database. now, some six years later, postgresql is mostly a match for mysql in speed, and mysql has added a lot of the 'real' database features that they were criticized for not having early on (although some of us will still not forget their attitude towards implementing them). there's not nearly as much reason to choose one over the other anymore as there used to be, but mysql had the advantage of early mindshare, so all of the websites talk about LAMP, and all of the books talk about "how to do X with mysql".

    personally i would never use mysql for data that i didn't want to risk losing, although i have no doubt that it has improved substantially since the last time i had the pleasure of using it. but that's just me.

    --
    If I don't put anything here, will anyone recognize me anymore?
  33. Re:Why MySQL and not PostGreSQL? (honest question! by dema · · Score: 2, Interesting

    personally i would never use mysql for data that i didn't want to risk losing

    I hear that a lot without much to say beyond it. But it seems like everytime MySQL and pgSQL come up it's hard to wade through all the zealotry and bs to find any real answers. What exactly do you (and presumably others) base your lack of trust in MySQL's data storage on? I've seen a few personal accounts about how MySQL has f'ed up and lost people's data, but do you know what kinds of things lead up to that? Or, why it would be more likely under MySQL than any other database?

  34. Doesn't everbody know? by galenoftheshadows · · Score: 2, Funny

    It's more fun to tear your hair out trying to figure out what went wrong! :-P

  35. Update is in order by WebCowboy · · Score: 4, Insightful

    This was a couple years ago so could be completely wrong now.

    No completely wrong, but mostly:

    * The current release of PgSQL runs natively on NT/2K/XP/2K3 Server as a service. The Cygwin emulation and related kludges are not an issue with either database now.

    * PgSQL has been quite optimised in recent years, while at the same time MySQL has become rather less lightweight than it used to be. The only way to get any measurable performance benefit from MySQL over PgSQL now is to forego the use of InnoDB tables in MySQL (and the transactional ACID-compliancy/rollback capability that comes with them). Even then, it is only fast at SELECTs--speed of INSERTs, UPDATEs and DELETEs was never MySQLs real strom point in any case.

    * As far as volume of hits and concurrent users go, PostgreSQL is far superior because it has a mature, stable MVCC (multi-version concurrency control) solution that almost completely eliminates table and record locking. If you have a site that does frequent and random insertion, deletion and modification transactions PgSQL wins.

    * MySQL was perhaps simpler in the past, but that was because it's capabilities were much more limited. It isn't hard to use today, but it isn't exeptionally easy anymore. Furthermore, PgSQL has a lot more tools to ease administration tasks than it used to. I am puzzled by comments that PgSQL us hard to use--I actually find it is easier to use than MS SQL Server 2000 now. The documentation has come a very long way and you can point-and-click your way around PgSQL with PgAdmin, WebMin, and various PHP web-based tools.

    * There are a lot of large-scale PgSQL implementations that rival or exceed Slashdot in scale. The entire .org domain relies on the PgSQL platform for example.

    Anyways, I hope I haven't offended MySQL fans--it is a fine product and has enjoyed a great deal of success and advancement with its association with SAP for example. For a typical blogger/slashdot-style site MySQL fits the bill nicely as it has the largest installed base, doesn't handle mission-critical data, and the vast majority of activity is read-only.

    If the data in the application is *important* and is write-heavy then you'll find that the case is different than above. For mission-critical web-based systems PostgreSQL tends to be be chosen over MySQL. For example, the SQL-Ledger accounting system uses PgSQL and NOT MySQL. However, MySQL has grown up some and has become a viable option here too--it's just that PgSQL has a more established image as being not the fastest but themost reliable with your data.

    Just remember that if you decide to pass on InnoDB to max out performance of your MySQL database you better make damn sure you have a reliable UPS and don't trip on the power cord or bump the emergency power disconnect switch or you'll have a crisis on your hands...

    1. Re:Update is in order by packman · · Score: 2, Insightful

      I agree that from the moment you need transactions & stuff or a seriously complicated database, you need Postgres. I'm not a Mysql fan at all, I use the best tool for the worst job but for web applications I seriously doubt Postgres has any chances in the mass-market because:

      1) Mysql has a much smaller memory-print. Try giving a database 4 or 8mb or ram to work with in both Postgres and Mysql and compare the performance. Postgres loses BIG time, while mysql runs without a glitch. Postgres is nice if you have 1 server dedicated to 1 application. Mysql is so popular because for low-end sollutions, it uses very little resources, which is exactly what mass-hosting companies need. Why do you think you see so little web-hosting with Postgres support?

      2) 95% of the queries performed by websites are typicly SELECT's - which is Mysql's strongest point.

      3) Most websites are not mission-critical. If you lose data - too bad, that are some blog's you lost, or maybe some reactions... Big deal. Btw - postgres's recovery after a powerfailure isn't perfect, I know a company that is switching to Oracle after a small postgres disaster half a year ago... They lost a rather critical table with +- 7 million records, and daily thousands are added.. Backup was from the day before, but they lost a whole day of pritty important transactions (crash happened at 21u in the evening, backup started at 21u30). No system is perfect, but now they have someone to blame...

      4) Postgres's duplication can't tip mysql's. In postgres quick hacks are available, Mysql supports load balancing and mirroring over multiple servers by default, and it's far superior to anything Postgres has.

      5) Postgres should be optimized for 1 application. There is no generic optimal configuration, differences in performance between applications can be extreme depending on the configuration.

      Mysql has it's purposes, so does Postgres, but I don't think they are competitors actually. It all depends on what you really need. I have experience with both, and for web-purposes - Mysql please... I plan looking into SQLite, which I already use for embedded purposes, but don't know how that is going to react in a multithreaded environment like a webserver.

  36. PEAR? by drew · · Score: 4, Interesting

    so, now that PHP actually has a complete, functional, and, most importantly, built in database abstraction layer, why are they still teaching people to use mysql_connect/query/etc?

    shouldn't everyone be using PEAR::DB by now?

    bad news when you decide you want to change your database because mysql can't handle the load without munging your data anymore....

    (ok, so the jab at mysql was flamebait, but the rest is a serious question....)

    --
    If I don't put anything here, will anyone recognize me anymore?
  37. Request for Comments by Darth_Burrito · · Score: 2, Interesting

    Lately I have been tasked with helping our communications department get on track with creation of a data driven website. At the moment, we're talking about helping two people. One is a graphic designer who manages a fairly large website. She has done a little bit of asp/access, but I don't think she understands it particularly well. She says she did a little php a long time ago. The other individual has been maintaining a filemaker database which presently contains data that is not in an optimal format for programming. This second individual has, using filemaker, managed to generate static pages off of the data (using some rather scary techniques). While they both have probably seen or written a few sql statements, I doubt they understood what they were doing.

    I am on loan to this department, so I can't just finish the project in a weekend and then hand it to them. Rather it's going to be a fairly long drawn out educational process (~2 months @ 1/2 time). They need to be able to understand how it works, how to maintain it, how to enhance it. Essentially they need to be an integral/invested part of the development process.

    Anyways, my initial idea was to have them use PHP alongside Pear's DB_DataObject and eventually Html_QuickForm libraries. For those not in the know, DB_DataObject is an object oriented data access layer generator framework thingy. Basically, instead of establishing connections, writing sql statements, and iterating over recordsets, they can write fairly simple code like the following.

    require_once('some-config-file.php');
    $student = new DB_Student(); // declaration
    $student->get(2); // gets the student with pri key=2
    print $student->name; // print's student's name.
    $student->name = "Bob Bobertson"; set students name.
    $student->update(); // commits name change

    Now when I see a newbie book teaching people to pound out their own sql and use old school mysql_connect style functions, I question my judgement. Is it a good idea or a bad idea to try to introduce these kinds of rapid development tools to novices? On one hand, these tools make my life easier on a daily basis. On the other hand, sometimes it's better to know the basics before going off to advanced topics like this. What do you guys think?

    It should be noted that whatever happens we are not sticking with filemaker (not even my decision). We will either be using Access which doesn't appear to be supported by DB_DataObject or potentially Access/ADP/MSDE or Access/Linked/MySQL which both do work with DB_DataObject. I am desperately trying to set up something that lets them create/edit/drop tables from within Access and lets them easily design queries in access which are then usable with DB_DataObject.

    Thus far, the closest I've come is using MSDE (light weight MS SQL Server) as the backend for Access. This is done using the Active Data Project (ADP) format not with linked tables. They can create/edit/drop tables and create views in Access. The views and tables are all reachable via DB_DataObject. However, there is no expression builder in the Access interface when working in this fashion.

    This is problematic because these folks are more accustomed to using wizards to dump all of their messed up logic right into their database software. I can see them wanting to create numerous complicated views but not knowing how unless they learn a sizable chunk of TSQL. If they have to do that, the value of a library like DB_DataObject, which prevents them from having to write sql, is significantly reduced.

    Personally, I think it all comes down to which they want to be easier: creating access forms/queries/etc or creating data driven web pages. Any thoughts?

    1. Re:Request for Comments by mabinogi · · Score: 2, Interesting

      > Now when I see a newbie book teaching people to pound out their own sql and use old school mysql_connect style functions, I question my judgement. Is it a good idea or a bad idea to try to introduce these kinds of rapid development tools to novices? On one hand, these tools make my life easier on a daily basis. On the other hand, sometimes it's better to know the basics before going off to advanced topics like this. What do you guys think?

      Object oriented data access layers can sometimes be useful - but sooner or later you're going to do a complex query spanning multiple tables, and you'll wish you used SQL.
      Usually the best approach is a combination, and if you design your data access layer correctly the SQL vs ORM decision doesn't have to be system wide.
      If you're using Java or .NET, then a tool like iBatis seems to be just the right balance between power, abstraction and simplicity. I don't know if something similar exists for PHP.

      Abstracting the database is ALWAYS a good thing. Books teaching the use of the mysql_* functions in PHP are simply WRONG, and should not be allowed to be sold. Those books are responsible for every slashdotted and vulnerable PHP site on the net, and contribute to the lack of good design principles.

      --
      Advanced users are users too!
  38. Nice book by Pan+T.+Hose · · Score: 2, Interesting

    First of all, this book seems like a nice rewrite of on-line documentation. It is even a good idea in principle, because building a database driven site with PHP and MySQL is indeed very quick, almost as quick as using Perl and SQLite, but as with every RDBMS there are gotchas. It is true for MySQL, true for PostgreSQL, true for SQLite and even for Oracle, because just like no system is secure, no database is perfect. You always have to know the gotchas to work around them, which is especially important when you want to write a portable database-independent application, which is always a good idea. Unfortunately, this book lacks many important informations about those issues, as it also lacks essential introduction to relational algebra, set theory and predicate calculus, which are important to understand the relational model and to know what the relational database is all about. Without such background, people tend to confuse the relational model with a SQL interface to the filesystem, or an object store, so the lack of such an introduction is the most important flaw of that book. Other than that, it is quite a nice rewrite of many HOWTOs available on-line, and it is always easier and quicker to read one book than to hunt countless websites. All in all, a nice book.

    --
    Sincerely,
    Pan Tarhei Hosé, PhD.
    "Homo sum et cogito ergo odi profanum vulgus et libido."
  39. I guess it might be worth mentioning ... by macaulay805 · · Score: 2, Interesting

    I guess it might be worth mentioning that when I built my first MySQL/PHP site, I used ADOdb. ADOdb is pretty slick! This is comming from a person who:

    1. Never programed in PHP! (Hell, never programed in ANYTHING before)
    2. Never did ANYTHING database related before!

    An all-general newbie to this kind of stuff. In one day, I learned how to create tables, insert data, display data on web pages, and all of the other basic stuff! At least a must-check-out for beginers! Ohh yeah, and "use the force, read the source" .. examples can really clarify things as well!

    PS - Must Explain why I still have a girlfriend!

  40. Dynamic website == slow and CPU heavy by jgarzik · · Score: 4, Insightful
    Unfortunately, the book review sounds like the book is missing information on one of my pet peeves:

    Fully dynamic websites will crush your server.

    Dynamic websites may be easy for beginners with this book, but introduce (a) a large amount of data or (b) a large amount of traffic (e.g. slashdot effect), and your server will fall over faster than a debutante in her first set of heels.

    I was on the team that helped set up cnn.com, back in the "early days" of the Web. And more recently, during the U.S. presidential debates, I convinced FactCheck.org that their server would stop falling over, if they just exported their article database as static HTML files, rather than being 100% dynamic. (that indeed fixed the problem)

    Dynamic content has its place, but too many newbies make the assumption that a fully dynamic website is a good idea. For content that does not change frequently, it is often more wise to use triggers to export the data as static HTML than to continually query and generate the same dynamic content over and over again. Database query caches help, but not a whole lot. Static HTML pages, and dynamic pages that provide the HTTP cache/expire/etag info are much more friendly to the web caching infrastructure in your browser and at your ISP.

  41. My PHP Slides by Sim9 · · Score: 2, Informative

    If anyone is interested in some extra resources for learning PHP, check out my powerpoint slides:

    http://www.cs.trinity.edu/~rzinchak/php/

  42. Re:PHP is the Visual Basic of the web. by Anonymous Coward · · Score: 2, Informative

    "Many mistakes can be made" with any language. If you think that specifying a particular technology will avoid mistakes, that's fine, but you will always have people who don't know anything about programming but can verifiably claim to know a language and will proceed to develop garbage. I think all of the popular languages for building web-based apps are on the wrong track in that none of them offer data dictionaries or similar workload-reducing features except in the form of third party packages. There is Zope with the CMF, but nobody seems to know how to use it (and the people who do probably had their own frameworks built in their language of choice before they ever saw it). Yes, PHP may be the Visual Basic of the web, but like VB, it is extremely powerful in the hands of a good programmer.

    We keep trying to solve problems with different languages when the real problem is with the programmers; they need training, they need to enjoy what they are doing, and they need to be encouraged to be good programmers, not coders in a specific language.

  43. Re:A PHP developer's review by MBraynard · · Score: 2, Informative
    See, here is why the book stinks compared to online. Obviously they have formats that are friendly not just to all OSes but also many languages.

    Take a look here

    Notice that there are notes. User notes. Those are often more valuable to me than the documentation. No book has those. That is why the online/print it out solution is infinitly better.