Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Connect to a database named "mary"
- $dbconn = pg_connect("dbname=mary");
- // Prepare a query for execution
- $result = pg_prepare($dbconn, "my_query", 'SELECT * FROM shops WHERE name = $1');
- // Execute the prepared query. Note that it is not necessary to escape
- // the string "Joe's Widgets" in any way
- $result = pg_execute($dbconn, "my_query", array("Joe's Widgets"));
- // Execute the same prepared query, this time with a different parameter
- $result = pg_execute($dbconn, "my_query", array("Clothes Clothes Clothes"));
- ?>
- <?php
- $pdo = new PDO('pgsql:dbname=example;user=me;password=pass;host=localhost;port=5432');
- $sql = "SELECT username, password
- FROM users
- WHERE username = :username
- AND password = :pass";
- $sth = $pdo->prepare($sql);
- $sth->execute(array(':username' => $_POST['username'], ':pass' => $_POST['password']));
- $result = $sth->fetchAll();
- <?php
- $pdo = new PDO('pgsql:dbname=example;user=me;password=pass;host=localhost;port=5432');
- $sql = "SELECT username, password
- FROM users
- WHERE username = ?
- AND password = ?";
- $sth = $pdo->prepare($sql);
- $sth->execute(array($_POST['username'], $_POST['password']));
- $result = $sth->fetchAll();
- $result = pg_prepare($dbconn, "my_query", 'SELECT * FROM shops WHERE name = $1');
- $result = pg_execute($dbconn, "my_query", array("Joe's Widgets"));
- $result = pg_execute($dbconn, "my_query", array("row two"));
- $result = pg_execute($dbconn, "my_query", array("row three"));
- $result = pg_prepare($dbconn, "query1", 'SELECT passhash_md5 FROM users WHERE email = $1');
- $result = pg_prepare($dbconn, "query1", 'SELECT passhash_md5 FROM users WHERE email = ?');
Add Comment
Please, Sign In to add comment