MySQL wrapper class problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

PHPHelpNeeded
Forum Commoner
Posts: 83
Joined: Mon Nov 17, 2014 8:03 pm

Re: MySQL wrapper class problem

Post 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?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: MySQL wrapper class problem

Post by Celauran »

You don't really need to. Because PHP is designed to execute and die, it will close it for you.
PHPHelpNeeded
Forum Commoner
Posts: 83
Joined: Mon Nov 17, 2014 8:03 pm

Re: MySQL wrapper class problem

Post 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
PHPHelpNeeded
Forum Commoner
Posts: 83
Joined: Mon Nov 17, 2014 8:03 pm

Re: MySQL wrapper class problem

Post 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?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: MySQL wrapper class problem

Post by Celauran »

Usually /var/lib/mysql on *nix systems. Not sure about Windows. Should be in your my.cnf file.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: MySQL wrapper class problem

Post 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.
PHPHelpNeeded
Forum Commoner
Posts: 83
Joined: Mon Nov 17, 2014 8:03 pm

Re: MySQL wrapper class problem

Post 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?
PHPHelpNeeded
Forum Commoner
Posts: 83
Joined: Mon Nov 17, 2014 8:03 pm

Re: MySQL wrapper class problem

Post 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.
PHPHelpNeeded
Forum Commoner
Posts: 83
Joined: Mon Nov 17, 2014 8:03 pm

Re: MySQL wrapper class problem

Post 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.
PHPHelpNeeded
Forum Commoner
Posts: 83
Joined: Mon Nov 17, 2014 8:03 pm

Re: MySQL wrapper class problem

Post by PHPHelpNeeded »

follow this post for the answer: viewtopic.php?f=1&t=140657
Post Reply