Permalink
Browse files

word wrapped

  • Loading branch information...
1 parent 209dcca commit be06fb9e05efd00d83a1e8f8206ab127c4f6dad7 @petdance committed Mar 7, 2012
Showing with 12 additions and 5 deletions.
  1. +12 −5 s/php.md
View
@@ -1,13 +1,21 @@
PHP
===
-PHP is a little more disorganized than how [Perl handles parameters](./perl.html). The standard [MySQL extension](http://php.net/manual/en/book.mysql.php) doesn't support parameterization, although the [PostgreSQL extension](http://www.php.net/manual/en/book.pgsql.php) does:
+PHP is a little more disorganized than how
+[Perl handles parameters](./perl.html).
+The standard [MySQL extension](http://php.net/manual/en/book.mysql.php)
+doesn't support parameterization, although the
+[PostgreSQL extension](http://www.php.net/manual/en/book.pgsql.php) does:
$result = pg_query_params( $dbh, 'SELECT * FROM users WHERE email = $1', array($email) );
-Note that the query must be in single-quotes or have the `$` escaped to avoid PHP trying to parse it as a variable.
+Note that the query must be in single-quotes or have the `$` escaped
+to avoid PHP trying to parse it as a variable.
-**However**, you should probably be using an abstraction layer. The [ODBC](http://php.net/manual/en/book.uodbc.php) and [PDO](http://www.php.net/manual/en/book.pdo.php) extensions both support parameterization and multiple databases:
+**However**, you should probably be using an abstraction layer.
+The [ODBC](http://php.net/manual/en/book.uodbc.php) and
+[PDO](http://www.php.net/manual/en/book.pdo.php) extensions both
+support parameterization and multiple databases:
Using mysqli
------------
@@ -38,7 +46,6 @@ Using the ODBC layer
Or:
$res = odbc_exec($conn, 'SELECT * FROM users WHERE email = ?', array($email));
-
$sth = $dbh->prepare('SELECT * FROM users WHERE email = :email');
$sth->execute(array(':email' => $email));
@@ -51,7 +58,7 @@ Here's the long way to do bind parameters.
$stmt = $dbh->prepare('INSERT INTO REGISTRY (name, value) VALUES (:name, :value)');
$stmt->bindParam(':name', $name);
$stmt->bindParam(':value', $value);
-
+
// insert one row
$name = 'one';
$value = 1;

0 comments on commit be06fb9

Please sign in to comment.