Pyh.conf’25: a new PHP conference for the Russian-speaking community

Voting

: four plus zero?
(Example: nine)

The Note You're Voting On

koalay at gmail dot com
15 years ago
Since regular expression is not supported by default SQLite, we can create a user function to do the job.

<?php

$db
= new SQLite3("database.sqlit3", 0666);

// create a function named "preg_match"
// with the php core function "preg_match"
if ($db->createFunction("preg_match", "preg_match", 2) === FALSE)
exit(
"Failed creating function\n");

// this query will then works as expected
$result = $db->query("SELECT * FROM table1 WHERE
preg_match('/^(apple|orange)$/', variable1)"
);

?>

<< Back to user notes page

To Top