homepage Welcome to WebmasterWorld Guest from 54.211.47.170
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP class to access MySQL database using mysqli
cfmtravel




msg:4643724
 5:13 pm on Feb 9, 2014 (gmt 0)

Hi

Do you know if there is a class (with all the methods for SELECT, COUNT, INSERT etc) that I can use to access MySQL db using mysqli?
I used to work with a class that unfortunately uses mysql and not mysqli.

Any suggestion?

Thanks

 

bethesda




msg:4645727
 12:58 pm on Feb 16, 2014 (gmt 0)

class ?
you are the man who create the class, then you cerate var for this class, then you create method(function) to this class where you put something like this, for example:


$db = new mysqli('dbhost', 'dbuser', 'dbpass', 'dbname');
$db -> query("SET NAMES 'latin2'");
$stmt = $db->stmt_init();
if($stmt->prepare("INSERT INTO `name` (`id`, `username`, `email`, `quantity`, `status`, `date` ) VALUES (?, ?, ?, ?, ?, NOW())")) {
$stmt->bind_param('issss', $a, $b, $c, $d, $e);
// Set your variables
$a = "mysql_real_escape_string(NULL)";
$b = "$var1";
$c = "$var2";
$d = "$var3";
$e = "$var4";
$stmt->execute();
if(!$stmt) {
$feedback = die(mysql_error());
echo 'UPS something goes wrong :).';
return $feedback;
$stmt->close();
$db->close();
} else {
$feedback = 'All ok !';
echo $feedback;
}}}}
$stmt->close();
$db->close();

penders




msg:4645845
 9:15 pm on Feb 16, 2014 (gmt 0)

@bethesda: I think the OP is after a wrapper/library for mysqli that provides more direct methods for SELECT, COUNT, etc. Similar (but a lot more than) the database class you posted in your other thread: www.webmasterworld.com/php/4645709.htm

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved