note 105808 added to ref.sqlite

From: Date: Fri, 16 Sep 2011 12:54:12 +0000
Subject: note 105808 added to ref.sqlite
Groups: php.notes 
Request: Send a blank email to php-notes+get-183214@lists.php.net to get a copy of this message
The SQLite manual mentions that queries are done in a case-sensitive way, this means your query must be the correct case. It also mentions that using the "LIKE" operator will do a case-insensitive selection. This is true, but this also introduces wildcard symbols which a user could enter without getting filtered by the SQLite escape function. I'm somewhat new to SQL and I didn't think of doing this before, even after looking for a decent way to do case-insensitive queries. For case-insensitive queries, simply use the built in "lower" function. <?php // ... $name = 'bARbarA'; $rows = $db->arrayQuery('select * from blah where lower(name) = lower(\''.sqlite_escape_string($name).'\');'); // $rows might contain an entry for "Barbara" now. ?> ---- Server IP: 69.147.83.197 Probable Submitter: 86.184.65.90 ---- Manual Page -- http://www.php.net/manual/en/ref.sqlite.php Edit -- https://master.php.net/note/edit/105808 Del: integrated -- https://master.php.net/note/delete/105808/integrated Del: useless -- https://master.php.net/note/delete/105808/useless Del: bad code -- https://master.php.net/note/delete/105808/bad+code Del: spam -- https://master.php.net/note/delete/105808/spam Del: non-english -- https://master.php.net/note/delete/105808/non-english Del: in docs -- https://master.php.net/note/delete/105808/in+docs Del: other reasons-- https://master.php.net/note/delete/105808 Reject -- https://master.php.net/note/reject/105808 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183214) next »