tntsearch icon indicating copy to clipboard operation
tntsearch copied to clipboard

Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format, MysqlEngine:68

Open menturion opened this issue 1 year ago • 4 comments

Hi, I am getting the following error:

PHP Fatal error: Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'TeamTNTTNTSearchStemmerNoStemmer' for column 'value' at row 2 in /MysqlEngine:68

https://github.com/teamtnt/tntsearch/blob/781e0eec1a1f56db0cdc2936849c508482b25547/src/Engines/MysqlEngine.php#L68

Without changing the types, I can solve this by disabling strict MySQL mode.

menturion avatar Dec 15 '24 09:12 menturion

https://github.com/teamtnt/tntsearch/blob/781e0eec1a1f56db0cdc2936849c508482b25547/src/Engines/MysqlEngine.php#L68-L72 needs to be escaped like ...

        $this->index->exec("INSERT INTO ".$this->indexName."_info ( `key`, `value`) values 
            ( 'total_documents', 0), 
            ( 'stemmer', 'TeamTNT\\\\TNTSearch\\\\Stemmer\\\\NoStemmer'), 
            ( 'tokenizer', 'TeamTNT\\\\TNTSearch\\\\Support\\\\Tokenizer')"
        );

Otherwise string "TeamTNTTNTSearchStemmerNoStemmer" gets stored in the DB which isn't a valid stemmer class instantiated at \teamtnt\tntsearch\src\TNTSearch.php:325, see ... https://github.com/teamtnt/tntsearch/blob/781e0eec1a1f56db0cdc2936849c508482b25547/src/TNTSearch.php#L325

menturion avatar Dec 15 '24 17:12 menturion

Hello @menturion

this should be fixed by the current release - the issue was that the value field was of type INT. But since there is a possible follow-up bug I created the pull request #340 :) It should take care of this issue.

leonardfischer avatar Jun 23 '25 18:06 leonardfischer

Hey @menturion this should be fixed now (in master). It has not been tagged yet, though 😅

leonardfischer avatar Jun 25 '25 13:06 leonardfischer

Hey @nticaric this should be fixed and can probably be closed, as soon as a new minor version gets released :)

leonardfischer avatar Sep 03 '25 08:09 leonardfischer