Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between bind_param() and bindParam()?

Tags:

php

pdo

I'm confused finding the difference between bind_param() and bindParam() as both are supported in PHP5 but one takes type as the first parameter and other takes a placeholder. Can someone give me an example of when to use one or the other?

like image 937
user2904995 Avatar asked Dec 04 '22 08:12

user2904995


2 Answers

bind_param is a method on mysqli_stmt:

mysqli_stmt - bind_param

bindParam is a method on PDOStatement:

PDOStatement - bindParam

The difference?

  • mysqli is a replacement for the deprecated mysql functions
  • PDO (PHP Data Objects) is a general database abstraction layer with support for MySQL, but also many other databases (sqlite, postgresql, oracle,...).

For more info look at this:

What is the difference between mysql, mysqli and pdo

like image 159
Jeroen Avatar answered Dec 11 '22 12:12

Jeroen


bind_param() is mysqli and bindParam() is PDO. Apples and Oranges.

like image 39
phil-lavin Avatar answered Dec 11 '22 10:12

phil-lavin