Asked  7 Months ago    Answers:  5   Viewed   32 times

Can someone tell me why I am getting this error? Call to undefined method PDO::bindParam()

Here is what I have, taken right off of PHPs site for stored procedures

$stmt = db::getInstance();
$stmt->prepare("CALL delete(?)");
$stmt->bindParam(2122, $return_value, PDO::PARAM_STR, 4000);
$stmt->execute();
print "procedure returned $return_valuen";

 Answers

100

The bindParam() method is inside the PDOStatement class, not the PDO class. The statement is the result of the prepare() method.

$foo = db::getInstance();
$stmt = $foo->prepare("CALL delete(?)");
$stmt->bindParam(2122, $return_value, PDO::PARAM_STR, 4000);
$stmt->execute();
print "procedure returned $return_valuen";
Wednesday, March 31, 2021
 
sholsinger
answered 7 Months ago
25

You dont have a function named assign(), but a method with this name. PHP is not Java and in PHP you have to make clear, if you want to call a function

assign()

or a method

$object->assign()

In your case the call to the function resides inside another method. $this always refers to the object, in which a method exists, itself.

$this->assign()
Wednesday, March 31, 2021
 
ericstumper
answered 7 Months ago
16
function __construct(){   $ingObject = new Ingredient();   }

ought to be

function __construct(){   $this->ingObject = new Ingredient();   }

In the first case you're setting a local variable, not a field, so it remains null. Then on the validateData you invoke a method on a null variable.

I'm assuming you snipped some code, because your Ingredient class doesn't make sense (there's a $validate variable there that isn't defined).

Wednesday, March 31, 2021
 
Alix
answered 7 Months ago
86

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario: http://confluence.jetbrains.com/display/PhpStorm/PHPUnit+Installation+via+Composer+in+PhpStorm

Related usability ticket: http://youtrack.jetbrains.com/issue/WI-18388

P.S. The WI-18388 ticket is already fixed in v8.0

Wednesday, March 31, 2021
 
ojrac
answered 7 Months ago
79

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Saturday, May 29, 2021
 
Nate
answered 5 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :