Permalink
Browse files

Added information about the CakePHP framework

  • Loading branch information...
1 parent 5ec1603 commit 01ec91e525d495a597007f26880d81765f6ce025 @lethal-guitar lethal-guitar committed Feb 7, 2013
Showing with 19 additions and 0 deletions.
  1. +19 −0 s/php.md
View
@@ -75,6 +75,25 @@ Here's a great [tutorial on migrating to PDO for MySQL developers](http://wiki.h
Applications & Frameworks
=========================
+CakePHP
+-------
+
+When using the MVC framework [CakePHP](http://cakephp.org/), most of your queries will be constructed automatically by the Model classes. Still, it is sometimes necessary to perform manual queries. The [Model::query](http://api.cakephp.org/class/model#method-Modelquery) method can be used to do that. In order to use prepared statements, you just need to pass an additional array parameter after the SQL query string. There are two variants:
+
+ // Unnamed placeholders: Pass an array containing one element for each ?,
+ // in the same order.
+ $this->MyModel->query(
+ 'SELECT name FROM users WHERE id = ?',
+ array($id)
+ );
+
+ // Named placeholders: Pass an associative array
+ $this->MyModel->query(
+ 'SELECT name FROM users WHERE id = :id AND status = :status',
+ array('id' => $id, 'status' => $status)
+ );
+
+
WordPress
---------

0 comments on commit 01ec91e

Please sign in to comment.