A Few Potential Enhancements

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 25, 2024   (RSS)

Here's a few things I've added over the years that have been useful to me in case they make sense to add to the codebase.

mysql_where(): support searching for NULL values

elseif (is_null($value)) {
    $where .= "`$fieldName` IS NULL AND ";
}
_getRecords_getQuery(): support selecting only part of the table for performance with large tables, support forcing an index
if (@$options['selectExpr']) {
    $selectFields = "`{$options['tableName']}`." . $options['selectExpr'];
}

// create query
$query = "SELECT $selectFields\n";
$query .= "FROM `" .DB::$tablePrefix. "{$options['tableName']}` as `{$options['tableName']}`\n";
$query .= (@$options['useIndex']) ? "USE INDEX ({$options['useIndex']})\n" : '';
$query .= $LEFT_JOIN;

...
_getRecords_getCountQuery(): useIndex same as getQuery()

isValidEmail(): prevent leading/trailing spaces from throwing an error since they don't break any mail functions I've found
$input = trim(is_string($input) ? $input : (string) $input);

By tbcshifter - September 25, 2024 - edited: September 25, 2024

For selectExpr, how are you using it?  getRecords() runs a lot of extra code, I'm wondering if calling mysql_select_query() directly would provide even more performance?

Not frequently, but mostly when there's a table with large text or blob fields that we want to exclude when fetching a bunch of records for memory sake, but we still want to take advantage of some of the extra getRecords() options.

By Dave - September 25, 2024

Makes sense, I'll add it to the next beta.  Thanks.

Dave Edis - Senior Developer
interactivetools.com