Page 2 of 2
Re: MySQL wrapper class problem
Posted: Thu Nov 27, 2014 12:18 pm
by PHPHelpNeeded
I think this will be the last question...
In the PDO php.net manual, in the function list of PDO library, I don't see the PDO:close() function, that if it exists, it could be used to close connection?
So how do you close the connection with the PDO library?
Re: MySQL wrapper class problem
Posted: Thu Nov 27, 2014 12:50 pm
by Celauran
You don't really need to. Because PHP is designed to execute and die, it will close it for you.
Re: MySQL wrapper class problem
Posted: Thu Nov 27, 2014 12:57 pm
by PHPHelpNeeded
Celauran wrote:You don't really need to. Because PHP is designed to execute and die, it will close it for you.
odd, but I guess it can work...
Thanks
Re: MySQL wrapper class problem
Posted: Thu Nov 27, 2014 12:59 pm
by PHPHelpNeeded
Ok, I am sorry but I have to ask this one more question.
When you create a database, where does the MySQL server saves the file?
Is it even possible to see? I mean when I open the MySQL Workbench, I don't seem to be able to see what database files have been created.
Any idea?
Re: MySQL wrapper class problem
Posted: Thu Nov 27, 2014 1:07 pm
by Celauran
Usually /var/lib/mysql on *nix systems. Not sure about Windows. Should be in your my.cnf file.
Re: MySQL wrapper class problem
Posted: Thu Nov 27, 2014 1:20 pm
by Weirdan
And it's not necessarily a separate file (or any file at all). InnoDB tables could be created in a shared tablespace, and this shared tablespace could live on a raw device. Granted, this setup is not all that common, and I don't think it's possible on Windows anyway.
Re: MySQL wrapper class problem
Posted: Thu Nov 27, 2014 2:40 pm
by PHPHelpNeeded
Something came up:
This is the code I have so far in the wrapper class for PDO.
Code: Select all
class PDO_MySQL_Wrapper {
private $db = null;
private $dbhost = null;
private $dbport = null;
private $dbuser = null;
private $dbpass = null;
private $dbname = null;
public function __construct($dbname, $dbhost, $dbport, $dbuser, $dbpass){
$this->dbname = $dbname;
$this->dbhost = $dbhost;
$this->dbport = $dbport;
$this->dbuser = $dbuser;
$this->dbpass = $dbpass;
}
public function db_connect(){
$this->db = new PDO("mysql:dbname=".$this->dbname.";host=".$this->dbhost.";port=".$this->dbport, $this->dbuser, $this->dbpass);//mysqli_connect($this->dbhost, $this->dbuser, $this->dbpass);
if(!$this->db){
throw new RuntimeException("Error: Could not connect to database. Please try again later.");
} else return true;
}
public function db_create($table){
if(($table = trim($table))!== NULL){
$sql = 'CREATE TABLE '.$table;
if ($this->db->query($sql)) {
return true;
} else {
return false;
}
} else return false;
}
public function db_delete($table){
if(($table = trim($table))!== NULL){
$sql = 'DROP TABLE '.$table;
if (mysqli_query($sql)) {
return true;
} else {
return false;
}
} else return false;
}
I only have made one thing differently for php.ini and that's to enable the following dll libraries as instructed by the php.net manual.
Code: Select all
extension=php_pdo.dll
extension=php_pdo_firebird.dll
extension=php_pdo_informix.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
extension=php_pdo_oci.dll
extension=php_pdo_oci8.dll
extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
but now when I run my program I get these error SYSTEM ERROR messages popup:
Code: Select all
the program can't start because fbclient.dll is missing from your computer. Try reinstalling the program to fix this problem.
The program can't start because OCI.dll is missing from your computer. Try reinstalling the program to fix this problem.
Do I have to reinstall PHP?
Re: MySQL wrapper class problem
Posted: Thu Nov 27, 2014 8:11 pm
by PHPHelpNeeded
I fixed it...the thing was that I was loading all the dll files as suggested from the installation instruction from php.net, but they all say, to load only the necessary, so I went back to the php.ini file and ; commented out some extensions and that fixed the problem.
Now I have to read carefully what I read about this sort of thing.
Re: MySQL wrapper class problem
Posted: Thu Nov 27, 2014 8:59 pm
by PHPHelpNeeded
I didn't quite fix it...I am still missing the php_pdo.dll file.
My php installation is from web platform installer...why is missing the file is beyond me.
I tried downloading php from php.net to see if that copy has the dll file but it does not.
Re: MySQL wrapper class problem
Posted: Fri Nov 28, 2014 7:13 pm
by PHPHelpNeeded
follow this post for the answer:
viewtopic.php?f=1&t=140657