|
Web Contractors Web Developer Jobs Join Us / Log in Discussion |
PHP Database Abstraction Layer
Submitted by rimian on Mon, 06/11/2007 - 11:26
If you're hunting around for a basic database abstraction layer for PHP/MySQl then here's one I found and tweaked a little that should work in php4
<?php
class database {
var $db;
var $query;
function database ( $host, $user, $pass, $db ) {
$this->db=mysql_connect($host,$user,$pass);
mysql_select_db($db,$this->db);
}
function query($sql) {
$this->query = mysql_query($sql,$this->db);
}
function getRow () {
if ( $row=mysql_fetch_array($this->query,MYSQL_ASSOC) )
return $row;
else
return false;
}
}
?>
<?php
//it goes something like this
$db = new database();
$sql = \"SELECT * FROM mytable\";
$db->query($sql);
$row = $db->getRow();
?>Enjoy! I'll write a php5 database abstraction layer soon...
New forum topics
- [MELB] Web Developer | Web Designer | Graphic Designer | Marketing Manager
- Open Source Online Invoicing Software
- Professional Drupal Consulting, Design & Development Services in Australia
- New Year Speacial-Professional Website for 400$ with doamin+Host
- Ruby on Rails Oceana
- WebDev/Design/Research/Consultant - PHP/MySql, Javascript, Joomla, HTML, Flash, AJAX
- Freelance ASP.NET Developer
- System Monitoring with Nagios
- Learning Ruby? What about the RubyMentor Project?
- Need a team
- JAOO Sydney/Brisbane 2009
- Get Your Business a Website for $399 ONLY !!!
- Concrete5: Another CMS!
- Manage The Cloud with Amazon Web Services
- Crystal Reports developer needed


Post new comment