[eluser]Phil Sturgeon[/eluser]
I understand what you mean. This isnt a very user contributed framework even though it is extremely awesome. This matter of improving the LIKE record has come up many times, however seeing as its a framework intended for programmers the user guide contains a fair amount of assument knowledge.
I'd personally like to see something like this added to /database/DB_active_rec:
Code:
/**
* Like
*
* Generates a &#xLI;KE% portion of the query. Separates
* multiple calls with AND
*
* @access public
* @param mixed
* @param mixed
* @return object
*/
function like($field, $match = '', $format = 'both')
{
return $this->_like($field, $match, $format, 'AND ');
}
// --------------------------------------------------------------------
/**
* OR Like
*
* Generates a &#xLI;KE% portion of the query. Separates
* multiple calls with OR
*
* @access public
* @param mixed
* @param mixed
* @return object
*/
function orlike($field, $match = '', $format = 'both')
{
return $this->_like($field, $match, $format, 'OR ');
}
// --------------------------------------------------------------------
/**
* Like
*
* Called by like() or orlike()
*
* @access private
* @param mixed
* @param mixed
* @param string
* @return object
*/
function _like($field, $match = '', $format = 'both', $type = 'AND ')
{
if ( ! is_array($field))
{
$field = array($field => $match);
}
foreach ($field as $k => $v)
{
$prefix = (count($this->ar_like) == 0) ? '' : $type;
$v = $this->escape_str($v);
switch($format):
case 'leading': $this->ar_like[] = $prefix." $k LIKE '%{$v}'"; break;
case 'trailing': $this->ar_like[] = $prefix." $k LIKE '{$v}%'"; break;
case 'both': $this->ar_like[] = $prefix." $k LIKE '%{$v}%'"; break;
endswitch;
}
return $this;
}
Want to take guesses at how long it took me to add support for that third parameter?
Give a penny to the most accurate guess.
A) 20 seconds
B) 5 minutes
C) 6 hours of hardcore development, testing and re-testing.
If it were option a, reckon I could get this added into the core?
I know derek is busy with development but how hard would it be to add nifty little changes like this into the framework that save eveyone time and effort. I'd be happy to add this into the user manual myself and make everyone happy!