$db = mysqli_connect('localhost', 'root', '');
$res = mysqli_query($db, 'CREATE DATABASE IF NOT EXISTS publications;');
$res = mysqli_query($db, 'USE publications;');
$res = mysqli_query($db, 'CREATE TABLE IF NOT EXISTS classics (author VARCHAR(128), title VARCHAR(128), type VARCHAR(16), year CHAR(4));');
$res = mysqli_multi_query($db, "INSERT INTO classics (author, title, type, year) VALUES ('Mark Twain','The Adventures of Tom Sawyer','Fiction','1876');
INSERT INTO classics (author, title, type, year)
VALUES ('Jane Austen','Pride and Prejudice','Fiction','1811');
INSERT INTO classics (author, title, type, year)
VALUES ('Charles Darwin','The Origin of Species','Non-Fiction','1856');
INSERT INTO classics (author, title, type, year)
VALUES ('Charles Dickens','The Origin out Shop','Fiction','1841');
INSERT INTO classics (author, title, type, year)
VALUES ('William Shakespeare','Romeo and Juliet','Play','1594');");
while (mysqli_next_result($db)) {}
mysqli_query($db, "ALTER TABLE classics ENGINE = MyISAM;");
mysqli_query($db, "ALTER TABLE classics ADD FULLTEXT(author, title);");
$res = mysqli_query($db, 'SELECT title FROM classics WHERE MATCH (title) AGAINST("Origin of" IN BOOLEAN MODE);');
var_dump(mysqli_fetch_all($res, MYSQLI_ASSOC));
Output:
array(2) {
[0]=>;
array(1) {
["title"]=>;
string(21) "The Origin of Species"
}
[1]=>;
array(1) {
["title"]=>;
string(19) "The Origin out Shop"
}
}