Я хотел случайным образом выбрать столбец из таблицы dictonary
в файле SQLite3.Но я не знаю, почему это дает мне предупреждение. (Обратите внимание)
Это код, который я пишу: (Часть)
<?php
class DB extends SQLite3{
function __construct($path){
return $this->open($path);
}
function randWord(){
//Randomize select a word from database.
$words = $this->query("select count(*) from 'dictonary';");
return $this->query("select * from 'dictonary' limit 1 offset ".mt_rand(0,$words-1).";")->fetchArray()['wholeWord'];
}
}
$database = new DB('storage.db');
echo json_encode([
'status'=>200,
'message'=>'Got an word!',
'data'=>[
'word'=>$database->randWord()
]
],JSON_PRETTY_PRINT);
$database->close();
И это ответ:
<br />
<b>Notice</b>: Object of class SQLite3Result could not be converted to int in <b>D:\phpStudy\htdocs\Files\word-match\api.php</b> on line <b>17</b><br />
{
"status": 200,
"message": "Got an word!",
"data": {
"word": "\u5b66\u795e\u4e4b\u5973"
}
}
Почему?