/    Sign up×
Community /Pin to ProfileBookmark

How do you communicate with mySQL? (Not a question, you personally)

OK, this is not a person needing help… I was just wondering what you guys use to communicate with mySQL? I use a class that I created… It makes it very easy… I know it’s bad, but oh well.. here’s mine:

[code=php]
<?php

/*

mySQL Database Class

Author: Nick Trevino <[email protected]>

Description: This class contains many functions that make using a mySQL database easier.

*/

// Set up the class…
class Db{
function Db(){
// In case the variables are already set…
global $db_name,$tbl_prefix,$sql_host,$sql_user,$sql_pass;
$this->dbName = $db_name;
$this->prefix = $tbl_prefix;
$this->sqlHost = $sql_host;
$this->sqlUser = $sql_user;
$this->sqlPass = $sql_pass;
}
function connect(){
$this->link = mysql_connect($this->sqlHost,$this->sqlUser,$this->sqlPass);
$this->error = mysql_error();
return mysql_select_db($this->dbName,$this->link);
}
function query($sql){
global $queries;
if(empty($sql))
return false;
$this->result = mysql_query($sql);
$this->error = mysql_error();
return $this->result;
}
function selectDB($db){
return mysql_select_db($db,$this->link);
}
function getRow(){
$this->row = mysql_fetch_row($this->result);
return $this->row;
}
function getError(){
return $this->error;
}
function rows(){
return mysql_num_rows($this->result);
}
function table($table){
return $this->prefix.$table;
}
function setDbName($dbName){
$this->dbName = $dbName;
}
function setSqlHost($host){
$this->sqlHost = $host;
}
function setSqlUser($user){
$this->sqlUser = $user;
}
function setSqlPass($pass){
$this->sqlPass = $pass;
}
}

$db = new Db;

?>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 11.2006 — See my sig. ?
Copy linkTweet thisAlerts:
@hyperliskauthorJul 11.2006 — Actually I was looking at it earlier, and it made me feel like making this topic.
×

Success!

Help @hyperlisk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...