I have controller that takes post parameters from HTML form, it will then send them to model that will insert the array into Cassandra database.
It is SQLInjection proof
In case you’re dealing with associative arrays and you don’t want to use array_intersect_key()
for any reason, you can also do a simpler approach of manually build a new array using the values you want from the old one.
$post = array(
'parent_id' => 1,
'type' => "post",
'title' => "Post title",
'body' => "Post body",
'tags' => "Post tags",
'malicious' => "Robert'); DROP TABLE students;--"
);
$good = array(
'parent_id' => $post['parent_id'],
'type' => $post['type'],
'title' => $post['title'],
'body' => $post['body'],
'tags' => $post['tags']
);