PHP Classes

Its never good idea to just pack everything in a single class.

Recommend this page to a friend!

      Best MySQL Class  >  All threads  >  Its never good idea to just pack...  >  (Un) Subscribe thread alerts  
Subject:Its never good idea to just pack...
Summary:Package rating comment
Messages:2
Author:gaj capuder
Date:2009-02-22 12:10:05
Update:2009-02-22 16:58:47
 

gaj capuder rated this package as follows:

Utility: Bad
Consistency: Not sure

  1. Its never good idea to just pack...   Reply   Report abuse  
Picture of gaj capuder gaj capuder - 2009-02-22 12:10:05
Its never good idea to just pack everything in a single class. Some general refactoring and functionality separation is needed here. Better to stick with php interal database functinalities.

  2. Re: Its never good idea to just pack...   Reply   Report abuse  
Picture of Ian Aldrighetti Ian Aldrighetti - 2009-02-22 16:58:47 - In reply to message 1 from gaj capuder
Um, Why..?

Other people seem to be liking it a lot. I see absolutely no reason whatso ever to put these things in multiple files. What would it accomplish that 1 file cannot?

And to be honest, I disagree with your "Better to stick with php interal database functinalities", due to the fact that you yourself would have to code less, for example:

// Procedural
mysql_connect('localhost','root','password');
mysql_select_db('your_db');

// Object Oriented
$db = new MySQL('localhost','root','password','your_db');

// Querying
// Procedural
$result = mysql_query("SELECT * FROM somewhere");
// or
$result = mysql_unbuffered_query("SELECT * FROM somewhere");

// Object Oriented
$result = $db->query("SELECT * FROM somewhere");
//or
$result = $db->query("SELECT * FROM somewhere", true);

// Escaping
// Procedural
$str = mysql_real_escape_string($str);

// Object Oriented
$str = $db->escape($str);



See where I am getting at? Less code for you... That and if you wanted to have multiple connections to multiples server (I don't know why) you would just make a new Object, however if you wanted to do it procedurally, you would then have to give the MySQL functions the connection handle, unlike with my object where it does it itself.