3
$stmt = $this->_db->prepare("SELECT userid FROM users WHERE login = ? AND md5pass = ?"); #$stmt->bindParam(1, $login, PDO::PARAM_INT); #$stmt->bindParam(2, $pass, PDO::PARAM_STR); $stmt->execute(array($login,$pass)); $res = $stmt->fetch(PDO::FETCH_NUM); 

Which way is better to transfer variables to prepeared statment bindParam or execute(array)? Both working but what is differense? Only PDO::PARAM checking? For SELECT I think array would be enough and for INSERT I sould use the bindParam. Am I right? Thanks to all. Just learning =)

2
  • You have answered your question yourself. Commented Mar 3, 2013 at 11:46
  • possible duplicate of PDO bindParam vs. execute Commented Jul 6, 2014 at 7:19

1 Answer 1

4

With bindParam you can add the datatype and also important with bind param you are binding the variables by reference.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.