Page 1 of 1

Using Conn() and prepared statements

Posted: Wed Aug 21, 2024 7:44 pm
by yaaryvp

Hello,

I used to connect with custom file to data using:

$db =& DbHelper();
$sql = "SELECT * from products;";
$result = $db->ExecuteRows($sql);

Now that this is depreciated, I try using

$conn = Conn();
$resultSet = $conn->executeQuery("SELECT * from products;");


echo "<pre>";
var_dump($resultSet);
echo "</pre>";

But i get the full object with password and username when I var_dump $resultSet

What am I doing wrong?


Re: $conn = Conn(); vs $db =& DbHelper();

Posted: Wed Aug 21, 2024 8:05 pm
by yaaryvp

The reason I wanted to use Conn() is seeing it supports prepared statements as such:

$count = $conn->executeStatement("UPDATE user SET username = ? WHERE id = ?", ["jwage", 1]); // Executes a prepared statement 

Do you happen to have an example of using prepared statements.
ty


Re: Conn() vs DbHelper()

Posted: Wed Aug 21, 2024 8:55 pm
by arbei

You may read Using Prepared Statements.

Note: Conn() returns DBAL connection object.