On 18/08/16 12:39, Rowan Collins wrote:
>> Is starting just a Firebird SQL thing or is it more generally available.
>> I do a few google searches but as usual when searching for things like
>> 'starting' one gets hundreds of pages on 'running' the software and it's
>> other connotations.
> 
> I've never come across it in Postgres, MS SQL Server, or MySQL.
> Generally LIKE 'abc%' is the recommended approach (and will I think hit
> the index in many cases, because the DBMS can optimize the case of a
> prefix match if it knows at planning time). A "starting" keyword would
> certainly be useful if it was there. :)
> 
> It doesn't quite fill the same need as a PHP function, of course,
> because you might be checking user input, or API results, or all sorts
> of things that won't, or haven't yet, hit the database. Currently the
> common idiom for that is the ugly strpos($string, 'abc') === 0

PHP is never going to be loading millions of records into memory and
searching them. That is the job of a database, and while LIKE 'abc%' can
be optimised to use an index and speed up results, if the 'abc%' is
supplied as a parameter that is not generally possible to prepare the
query using an index. While STARTING always knows the matching string is
the first characters of the index. While PHP and SQL share a number of
alternatives, the SQL versions will have a premium on search time if an
index can't be used.

I was just wondering if str_starting and str_ending matched better with
other string handling options.

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to