Why when I try to use PDO::PARAM_STR in Slim3, Slim return an error?

Louis-Antoine Shelby

Can somebody explain me why when I try to use PDO::PARAM_STR in my code, SLIM3 returns me an error ?

 $app->add(new \App\Middlewares\BddMiddleware($Cpdo, $Ctwig));

 class BddMiddleware {

    private $pdo;
    private $twig;

    public function __construct($pdo, $twig)
    {
        $this->pdo = $pdo;
        $this->twig = $twig;
    }

    public function __invoke($request, $response, $next){
        $query = $this->pdo->prepare('SELECT * FROM projet WHERE name = :name');
        $query->bindParam(':name', $path, PDO::PARAM_STR);
        $query->execute();
        $projet = $query->fetch();

I do not understand...

This is my container :

$container['pdo'] = function(){
    $pdo = new PDO('mysql:dbname=portfolio;host=localhost','root','', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
    return $pdo;
};

this doesn't work either..

$query->bindParam(':name', $path, $this->pdo(PDO::PARAM_STR));
Zamrony P. Juhara

Without exact error message, I can only guess. Make sure that you add

use PDO;

on top of BddMiddleware class.

To be able to view error messages, turn on Slim debug information by changing application configuration to include following values:

$config = [  
    'settings' => [
        ...
        'debug' => true,
        'displayErrorDetails' => true,
        ...
    ],
]; 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

I have a parse error using eloquent with slim3

Proguard return an error when I try to use it in Eclipse

Why is this error showing when I try to use javaws?

Fatal error: Uncaught Error: Class 'maimana\App' not found -- slim3

twig error when using in slim

When i try to use method it give error

Why I obtain this error message when I try to use the Maven assembly plugin?

I get an error when I try to use ROW_NUMBER(), why?

I get a syntax error when I try to use array map function in Google Scripts. Why?

Why I have this error when I try to use my own CollectionViewCell class?

why do i get an error when i try to use my models?

Slim 3 - Error is not shown

Why is Android Studio showing an error when I try to use setText() on a Button?

Why when I try to use models in celery tasks django raises "Apps aren't loaded yet" error?

SLIM Error :: AuthController not found when SLIM app hosted on server

Rendering Zend Form in Slim3

Slim3 Container good practice?

Slim3 PSR-4 autoloader

Why can't I return when catching an exception with try:?

Why does this return -1 when I try to find .IndexOf(a) in the list?

Why None is returned during recursion when i try to return count?

return not work when I use setTimeout in try-catch

Why use "slim = tf.contrib.slim" instead of import slim normally?

Why I get exception when I try to use AutoMapper?

Why I get error when I try to declare local variable?

Why I get error when I try to create stored procedure?

Why do I get an error for "__CrtGetFileInformationByHandleEx " when I try to compile

Why I get error when I try to install pyaudio?

Why I get an error when I try to upload a picture