|
mfrijmann - 2012-02-13 17:50:59
i've downloaded you're class and included it in my script:
require_once("class_pdo_db.php");
$db = new wArLeY_DBMS("mysql", "localhost", "xxxx", "xxxx", "xxxx", "");
$db = $db->Cnxn(); //This step is neccesary for create connection to database, and getting the errors in methods.
if($db==false){
die("Error: Cant connect to database.");
}
$params = array(":module@27@INT");
$rows = $db->query_secure("SELECT id,name FROM devices WHERE module > :module;", $params, true);
if($rows!=false){
foreach($rows as $row){
$name = $row["name"];
echo $name . "<br />";
$count++;
}
}
$rows = null;
echo $db->getError();
And i'm getting the following error:
Fatal error: Call to undefined method PDO::query_secure()
on row:
$rows = $db->query_secure("SELECT id,name FROM devices WHERE module > :module;", $params, true);
What i;m i doing wrong?
Ignacio Colautti - 2012-02-13 18:10:44 - In reply to message 1 from mfrijmann
This is wrong:
$db = $db->Cnxn();
After that line, $db is PDO object, and not a wArLeY_DBMS one.
Change to this:
if($db->Cnxn() == false)
die("Error: Cant connect to database.");
mfrijmann - 2012-02-13 19:04:48 - In reply to message 2 from Ignacio Colautti
I Works!
Thanks for you quick response!
I copied it from the manual:
//First you need include the class file
require("pdo_database.class.php");
//Intance the class
$db = new wArLeY_DBMS("mysql", "10.33.133.133", "test", "root", "", "");
$db = $db->Cnxn(); //This step is neccesary for create connection to database, and getting the errors in methods.
if($db==false){
die("Error: Cant connect to database.");
}
is this a bug in the manual, or .... ?
Matias Lecaros - 2012-02-26 23:09:09 - In reply to message 2 from Ignacio Colautti
thx! :)
Evert Ulises German Soto - 2012-03-08 18:40:05 - In reply to message 2 from Ignacio Colautti
Thanks Ignacio for your correct anwer.
I have an error in the manual... now is fixed.
Evert Ulises German Soto - 2012-03-08 18:42:16 - In reply to message 3 from mfrijmann
mfrijmann so sorry... yes is a little bug in the manual.
and thanks to Ignacio for the quick response.
the bug was fixed in the manual.
Marco Rossi - 2012-07-03 08:00:40 - In reply to message 1 from mfrijmann
Hi! The normal query works perfectly, but if i make:
//SELECT statement with option "NAMED PLACEHOLDERS":
$params = array(":id|2|INT");
$rows = $db_pdo->query_secure("SELECT Username,User_ID FROM my_users WHERE User_ID=:id;", $params, false);
if($rows!=false){
foreach($rows as $row){
$User_ID = $row["User_ID"];
$Username = $row["Username"];
echo "Hai username: <b>". $Username ."</b> ed hai ID: ".$User_ID."<br />";
}
}
$rows = null;
i don't receive nothing....where is my problem?
Thanks to all!
Marco Rossi - 2012-07-03 08:12:25 - In reply to message 7 from Marco Rossi
I resolved, the problem was that the value must to be "true" to get recordset :) byez!!
Evert Ulises German Soto - 2012-07-18 17:57:19 - In reply to message 8 from Marco Rossi
Is correct Marco Rossi... the fourth param must be true for use the explicit types. Is too late i know but im glad you've solved your problem.
Regards!
|