Manticore 4.2.0 is bugging out when attempting to connect through PHP. It returns the error “Fatal error: Uncaught PDOException: SQLSTATE[08S01]: Communication link failure: 1047 unknown command (code=22)”.
My code works perfectly OK with Manticore versions 3.5.2, 3.5.4, 3.6.0, 4.0.2, but whenever I switch to version 4.2.0 I get this bug.
I can run the Manticore statement by logging into the server manually and that works fine in 4.2.0, but the same statement in PHP bugs out.
The error occurs either on prepare or execute and seems to connect to the Manticore server without issue.
Here’s my code:
$man_opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, // terminates script
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
$man_conn = new PDO('mysql:host=127.0.0.1;port=9306;charset=utf8mb4', null, null, $man_opt);
} catch (PDOException $e) {
$error_message = $e->getMessage();
// send email and log the error
manticore_error_email_log($error_message);
}
$man_query = 'SELECT country, city, country_code, latitude, longitude, INTEGER((WEIGHT()*120)+(population)) AS myorder FROM geolocations WHERE MATCH(:query) ORDER BY myorder DESC limit 1 OPTION field_weights=(country=10, state=9, county=9, city=9, state_code=9), ranker=expr(\'(sum(lcs*user_weight)*1000+bm25) * IF(country = "united states" OR country = "united kingdom", 1.25, 1)\')';
$man_stmt = $man_conn->prepare($man_query);
$man_stmt->execute(['query' => '@(country,state,county,city,state_code) "^' . $location . '$"/0.75']);
$geocode_data = $man_stmt->fetch();
As mentioned above, if I run the same statement directly inside Manticore 4.2.0 it works e.g
SELECT country, city, country_code, latitude, longitude, INTEGER((WEIGHT()*120)+(population))
AS myorder FROM geolocations WHERE MATCH('@(country,state,county,city,state_code) "^Grimsby$"/0.75') ORDER BY myorder DESC limit 1 OPTION field_weights=(country=10, state=9, county=9, city=9, state_code=9), ranker=expr('(sum(lcs*user_weight)*1000+bm25) * IF(country = "united states" OR country = "united kingdom", 1.25, 1)');