jfr
4 months ago
1113
4
Lumen

SQLSTATE[HY000] [2002] No such file or directory

Posted 4 months ago by jfr

Hello,

I get this error:

SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `results` where `finalHouse` = ravenclaw)

in Connection.php line 664
at Connection -> runQueryCallback( 'select * from `results` where `finalHouse` = ?', array('ravenclaw'), object( Closure) )
in Connection.php line 624
at Connection -> run( 'select * from `results` where `finalHouse` = ?', array('ravenclaw'), object( Closure) )
in Connection.php line 333

(yes, I'm building a harry potter test ;) )

This is the code I'm writing:

$houses = ['ravenclaw', 'gryffindor', 'hufflepuff', 'slytherin'];
$results = [];
foreach ($houses as $key => $house) {
    $results[$key] = DB::table('results')->select('*')->where('finalHouse', $house)->get();
}   

$house is always a string, also when I var_dump it. I tried several things, but it kind of converts the string to... whatever it is? It is converting in the get(), in the getBindings() array is the string still a string. finalHouse is an enum in the database (also changed it to varchar, but doesn't make a difference). Using PHP 7.2.14 and Lumen 5.8. Can anyone help me? I have the feeling I oversee something really obvious.

Please sign in or create an account to participate in this conversation.