aboskoco
asked on
PEAR
Hello,
Is PEAR a safer way to access mysql database?
Does PEAR have a slower return then a regular database query?
How to I translate the simple queries into PEAR:
1. $sql = mysql_query("SELECT * FROM x WHERE username='$username' AND id='$id'");
$ok = mysql_num_rows($sql);
2. $sql2 = mysql_query("SELECT COUNT(*) as TOTALFOUND from inbox WHERE username='$username' and checked='n'"); print(mysql_result($my_tab le,0,"TOTA LFOUND"));
3. $insert=mysql_query ("INSERT INTO ib (username, fromuser)
VALUES ('$to','$from')") or die (mysql_error());
4. $update=mysql_query("UPDAT E c SET profile='$updatec' WHERE id='$id'") or die (mysql_error());
Thanks!!!
Is PEAR a safer way to access mysql database?
Does PEAR have a slower return then a regular database query?
How to I translate the simple queries into PEAR:
1. $sql = mysql_query("SELECT * FROM x WHERE username='$username' AND id='$id'");
$ok = mysql_num_rows($sql);
2. $sql2 = mysql_query("SELECT COUNT(*) as TOTALFOUND from inbox WHERE username='$username' and checked='n'"); print(mysql_result($my_tab
3. $insert=mysql_query ("INSERT INTO ib (username, fromuser)
VALUES ('$to','$from')") or die (mysql_error());
4. $update=mysql_query("UPDAT
Thanks!!!
ASKER
I have been informed by others just the opposite.
PEAR::DB, the database abstraction library is what has been mentioned to me.
PEAR::DB, the database abstraction library is what has been mentioned to me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you. Point well taken
My main reason for wanting to learn pear is because it is supposedly far more hacker safe, is this correct?...
require_once 'MDB2.php'; = what is this referring to?
$row = mysql_fetch_array($res) - does this still apply or does pear use a separate way to create this array?
My main reason for wanting to learn pear is because it is supposedly far more hacker safe, is this correct?...
require_once 'MDB2.php'; = what is this referring to?
$row = mysql_fetch_array($res) - does this still apply or does pear use a separate way to create this array?
In general your server would have the PEAR package directory as part of its include path.
So when you do require_once 'MDB2.php' it should load MDB2.php in the PEAR directory.
I think you cannot use use mysql_fetch_array($res) because MDB2 doesn't return the result of mysql_query, but it creates its own result object, which is not depending on a specific database scheme. The MDB2 greatest power might just be that you can hook it to oracle, postgres, mysql without having to change all your code, except possibly your queries that use database-specific syntax.
You can use:
$row = $res->fetchRow();
-r-
So when you do require_once 'MDB2.php' it should load MDB2.php in the PEAR directory.
I think you cannot use use mysql_fetch_array($res) because MDB2 doesn't return the result of mysql_query, but it creates its own result object, which is not depending on a specific database scheme. The MDB2 greatest power might just be that you can hook it to oracle, postgres, mysql without having to change all your code, except possibly your queries that use database-specific syntax.
You can use:
$row = $res->fetchRow();
-r-
PEAR contains classes that provide ways of accessing databases like mysql.
There are several classes, and pear can be slower then plain mysql_connect/query calls because of additional functionality.
-r-