User Tools

Site Tools


libraries:databaseconnector:practicalexamples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
libraries:databaseconnector:practicalexamples [2023/03/06 11:22] michael.pohllibraries:databaseconnector:practicalexamples [2023/03/31 19:27] (current) michael.pohl
Line 98: Line 98:
 else else
 { {
 +   // Example 1 - Working with unnamed placeholders -------------------------------
    // Preparing a statement for getting a user's session id by    // Preparing a statement for getting a user's session id by
    // username and passwort sent with a POST-Request    // username and passwort sent with a POST-Request
-   $DB->SqlPrepareStatement("SELECT session FROM tbl_users WHERE LOWER(username) = '?AND password = '?'");+   $DB->SqlPrepareStatement("SELECT session FROM tbl_users WHERE LOWER(username) = ? AND password = ?");
  
-   $Result = $DB->SqlGetPreparedLines( $_POST['username'], $_POST['password'] );+   $Result = $DB->SqlGetPreparedLines( array($_POST['username'], $_POST['password']) ); 
 +    
 +   // Example 2 - Working with named placeholders ------------------------------- 
 +   // Preparing a statement for getting a user's session id by 
 +   // username and passwort sent with a POST-Request 
 +   $DB->SqlPrepareStatement("SELECT session FROM tbl_users WHERE LOWER(username) = :user AND password = :pass"); 
 + 
 +   $Result = $DB->SqlGetPreparedLines( array('user' => $_POST['username'], 'pass' => $_POST['password']) );
  
    if ($Result === FALSE)    if ($Result === FALSE)
libraries/databaseconnector/practicalexamples.txt · Last modified: 2023/03/31 19:27 by michael.pohl