Jump to content

Recommended Posts

Posted

Why not just use PDO?

http://us2.php.net/pdo

PDO does pretty much what you're trying to do. It provides an object-oriented structure and a proper interface for prepared statements. It doesn't use mysql_* functions but it has equivalents.

Here's a PDO script from start to finish:

<?php
new PDO('mysql:host=localhost;dbname=somedb','user','pass');
$sql = 'SELECT * FROM `sometable` WHERE `somecol`=?';
$sth = $dbh->prepare($sql); // prepared statements woo!
$sth->execute(array('somevalue')); // ^
$out = $sth->fetchAll();
var_dump($out);
?>

 

Dont see how that would do everything in the tutorial to be honest. Just a different way to connect and execute sql

Posted

Why not just use PDO?

http://us2.php.net/pdo

PDO does pretty much what you're trying to do. It provides an object-oriented structure and a proper interface for prepared statements. It doesn't use mysql_* functions but it has equivalents.

Here's a PDO script from start to finish:

<?php
new PDO('mysql:host=localhost;dbname=somedb','user','pass');
$sql = 'SELECT * FROM `sometable` WHERE `somecol`=?';
$sth = $dbh->prepare($sql); // prepared statements woo!
$sth->execute(array('somevalue')); // ^
$out = $sth->fetchAll();
var_dump($out);
?>

 

You certainly can use PDO if you want :)

 

But if you want a minimal and robust DAL then that's what the tutorial is for.

 

Look libraries are fantastic things. However there seems to be an entire generation of "Software Engineers" that have become so dependent on frameworks and libraries that they are just "glue programming".

 

As an example:

 

One of our flagship internal enterprise company application has a virtual case board. It was originally created using off the shelf libraries. The performance was shockingly bad.

 

I scrapped the entire module and re-wrote it by hand, using no libraries or frameworks.

 

The result?

 

The entire code was only a few hundred lines long versus the thousands of lines when you consider all the libraries and frameworks.

 

I'm not suggesting not using libraries, you most certainly should. But at the same time, you should know how to roll things from scratch too.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...