By default, Recess PHPs’s JsonView class responds with the properties of your controller. So even if you create a custom route that outputs only an array, a default row of the controller’s model will also be included with null values.
You can override this using the OKResponse class. You can do it like this.
I am not sure if this is a matter of one’s preference but I believe from my experience PDO provides more coding flexibility that MySQLi.
Here is an example so you will better understand what I mean.
PHP
1
2
3
4
5
6
7
8
$query='select from tablename where id = ?';
$params=array($id);
if($name!=''){
$query.=' and name = ?';
array_push($params,$name);
}
$stmt=$db->prepare($query);
$stmt->execute($params);
Now, if that were to be MySQLi, I would be doing it like this:
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
$query='select from tablename where id = ?';
if($name!=''){
$query.=' and name = ?';
}
$stmt=$db->prepare($query);
$stmt->bind_param('s',$id);
if($name!=''){
$stmt->bind_param('s',$name);
}
$stmt->execute();
Notice the difference? I had to call if conditions twice. If my query is very long, then my code would also be long.
Plus, there is also the issue of mysqli_escape_string(). With PDO, you do not have to call one since it calls that function automatically when you bind values to the parameters.
When I started using prepared statements in MySQL because of the SQL injection issue, this is the main reason why I opted to use PDO rather than MySQLi.