kphp icon indicating copy to clipboard operation
kphp copied to clipboard

PDO prepared statements

Open astrophysik opened this issue 2 years ago • 0 comments

In PHP there are prepared statements to speed up and simplify the work with PDO

Example:

$request = $db->prepare('SELECT * FROM issues WHERE likes < :likes AND author = :author');
$request->execute(['likes' => 100, 'author' => 'Einstein']);
$answers = $request->fetchAll();

This functionality should be added to KPHP because:

  • It can protect code from SQL injections
  • It helps speed up queries, since the database can parse the expression

astrophysik avatar Feb 22 '23 13:02 astrophysik