note 104978 deleted from function.sqlite-create-function by cmb

From: Date: Mon, 02 Nov 2020 14:58:28 +0000
Subject: note 104978 deleted from function.sqlite-create-function by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215722@lists.php.net to get a copy of this message
Note Submitter: Dodolidet ---- Although you can create an UDF named 'regexp()', I think it won't be registered as REGEXP operator.. <?php //registering REGEXP function my_sqlite_regexp($x,$y){ return (int)preg_match("$yi",$x); } echo $db->createFunction('regexp','my_sqlite_regexp',2); //testing regexp as function, working $res = $db->query("SELECT * FROM x WHERE regexp(c,'h')", SQLITE_ASSOC , $err) ; //testing regexp as operator, not working, near "REGEXP": syntax error $res = $db->query("SELECT * FROM x WHERE c REGEXP 'h'", SQLITE_ASSOC , $err); ?> I'd also swapped the function parameters $x and $y, but also not works.. ----- From SQLite documentation: "The REGEXP operator is a special syntax for the regexp() user function. No regexp() user function is defined by default and so use of the REGEXP operator will normally result in an error message. If a application-defined SQL function named "regexp" is added at run-time, that function will be called in order to implement the REGEXP operator."

« previous php.notes (#215722) next »