Reputation: 406
I have a problem with a fulltext search query which works before I updated phpmyadmin I think. Lets start:
I get from the first select query a array named $keywordse
with $keywordse = $resi->fetchAll(PDO::FETCH_ASSOC);
If I run var_dump($keywordse);
I get the following output:
array(1) { [0]=> array(4) {
["keyword1"]=> string(4) "test"
["keyword2"]=> string(5) "asdfr"
["keyword3"]=> string(4) "roof"
} }
After the first query I added $keywordsonetoeight = implode(',', $keywordse);
to convert the array for the second query. At this line I get
Notice: Array to string conversion
the second query:
try {
$dbh = new PDO("mysql:host=$hostname;dbname=loginsystem",$user,$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //
$sql = "SELECT id, autorid, autor, title, text, time
FROM posts
WHERE MATCH (title, text) AGAINST ('$keywordsonetoeight')
ORDER BY id DESC";
if ($res = $dbh->query($sql)) {// need to add this line in your code
// then after fetchColumn
$result = $res->fetchAll();
}
}
catch(PDOException $e)
{
//echo $e->getMessage();
}
Is there anything wrong with the second query or with the the variable $keywordsonetoeight
?
Upvotes: 0
Views: 60
Reputation: 1328
your conversion is wrong, you must convert the first entry of $keywordse to get the keywords as a string.
$keywordsonetoeight = implode(',', $keywordse[0]);
I am not sure if comma seperated is correct maybe you just need spaces in the query, but I cannot check this right now.
Upvotes: 1