FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Parameterized queries with MariaDB
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Parameterized queries with MariaDB
Posted: Sat Mar 22, 2025 06:26 PM
Hello Everyone;

Parameterized queries are key to preventing SQL injection in any SQL including MariaDB. However, in MariaDB (and MySQL), the parameterization itself is handled at the level of the client application, not in SQL syntax directly.

Parameterized queries are also a lot faster when executed inside a loop many times, as the server only parses the SQL once.

Here is a sample code using PHP of a parameterized query with MariaDB.
$mysqli = new mysqli("localhost", "user", "password", "database");

$stmt = $mysqli->prepare("SELECT * FROM users WHERE username = ?");
$stmt->bind_param("s", $username); // 's' means string
$username = "rcrespo";
$stmt->execute();

$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
    print_r($row);
}
Does fwh maria class supports parameterized queries?

Thank you.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Parameterized queries with MariaDB
Posted: Sat Mar 22, 2025 11:38 PM
Reinaldo, try
cSql     := "SHOW FULL TABLES IN `?` LIKE ?"
oMysql:Execute( cSql, { npar1, npar2 } )    // Example with two parameters
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces

Continue the discussion