// post · 145
Going to Classes means less work.
Yes that is right everyone. Go to classes now!
I've just spend the last few hours playing with Classes in php; and wow what a difference.
I've just coded myself a mysql database class. This class connects to the database plus processes queries. The processing queries section is really useful for two reasons:
1) Cuts back on code as I do not need to retype anything. If I wanted to count how many rows there are in a table the old code would look like this:
$query = "SELECT count(*) FROM news";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo $row['count'];
The new one is simply:
echo $database->numofrows("SELECT count(*) FROM news");
2) I can now change over to another database system if needed. All I do is replace my mysql class with another class. No other code change is needed.
If you're running Wordpress you're lucky enough to have programmers who know what they're doing. WP already uses classes.
So who here has found the wonders of classes?
I've just spend the last few hours playing with Classes in php; and wow what a difference.
I've just coded myself a mysql database class. This class connects to the database plus processes queries. The processing queries section is really useful for two reasons:
1) Cuts back on code as I do not need to retype anything. If I wanted to count how many rows there are in a table the old code would look like this:
$query = "SELECT count(*) FROM news";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo $row['count'];
The new one is simply:
echo $database->numofrows("SELECT count(*) FROM news");
2) I can now change over to another database system if needed. All I do is replace my mysql class with another class. No other code change is needed.
If you're running Wordpress you're lucky enough to have programmers who know what they're doing. WP already uses classes.
So who here has found the wonders of classes?
// leave a comment
HTML allowed: <a href="" title="" rel=""></a> <b></b> <blockquote cite=""></blockquote> <em></em> <i></i> <strike></strike> <strong></strong> <li></li> <ol></ol> <ul></ul>
ie: <b>bold</b>
Your comment may need to be reviewed before it is published.
// comments