Page 1 of 1

What does the PHP Manual mean about using mysql and mysqli?

Posted: Mon Aug 27, 2007 12:09 pm
by ssmela
According to the PHP Manual,

"If you would like to install the mysql extension along with the mysqli extension you have to use the same client library to avoid any conflicts."

I find this confusing because I have two dll libraries installed on my Windows XAMP system:

(1) php_mysql.dll
(2) php_mysqli.dll

I seem to be able to use functions from both of these libraries, so I am confused as to what the PHP manual is saying.

Also, I was looking at a piece of code that has the following statement:

Code: Select all

$cnt=$db->get_var("select count(*) from categories_description");
Where can I find information on the get_var method. Is this a part of mysqli?

Thank you.

Posted: Mon Aug 27, 2007 12:29 pm
by Zoxive

Code: Select all

$cnt=$db->get_var("select count(*) from categories_description");
$db is an Instance of a Class, and get_var is a function in that class.

Not quite sure where you got that snippet from.

Posted: Mon Aug 27, 2007 1:49 pm
by ssmela
OK sorry I should have given more information on the question about "get_var ".

Here is the more complete example.

Code: Select all

$connection = mysql_connect("localhost",$Login,$Password) or die("Couldn't make a connection.");
$db = mysql_select_db($theDB, $connection) or die("Couldn't select database.");
$cnt=$db->get_var("select count(*) from categories_description");
Where can I find information on the get_var method. Is this a part of mysqli?

Thank you

Posted: Mon Aug 27, 2007 2:36 pm
by volka
mysql_select_db returns a boolean (i.e. TRUE or FALSE).
Therefore $db->get_var in your script must fail since $db is not an object.
Did you actually copy that code snippet? If you did: From where?

Re: What does the PHP Manual mean about using mysql and mysq

Posted: Mon Aug 27, 2007 2:54 pm
by timvw
ssmela wrote: "If you would like to install the mysql extension along with the mysqli extension you have to use the same client library to avoid any conflicts."
I seem to be able to use functions from both of these libraries, so I am confused as to what the PHP manual is saying.
AFAIK the manual is talking about libmysql (a library that both the mysql and mysqli extension use)... So, unless you start building your own binaries it's not something you should think about (and even if you build your own, it's rather uncommon that you would want to use two different versions.)