note 120247 deleted from function.sqlite-create-function by cmb
| From: | cmb@php.net | Date: | Mon, 02 Nov 2020 14:58:19 +0000 |
| Subject: | note 120247 deleted from function.sqlite-create-function by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215721@lists.php.net to get a copy of this message | ||
Note Submitter: anrdaemon at freemail dot ru
----
The (probably) all too often requested regexp() function actually works just fine.
<?php
$db = new PDO('sqlite::memory:', null, null, [PDO::ATTR_ERRMODE =>
PDO::ERRMODE_EXCEPTION]);
$db->sqliteCreateFunction('regexp', function($y, $x) { return preg_match('/'
. addcslashes($y, '/') . '/', $x); }, 2);
$db->query('SELECT ("Things!" REGEXP "^T")
result');
?>