string length(string $columnName)
The method length() returns a database specific SQL statement that returns the length of data in a field. This happens even if the field is defined as a fixed length CHAR field, because the field is trimmed before the length of the data is obtained.
/* * Assume MySQL database */ $sql = $db->length(some_string_field); /* * Returns: LENGTH(TRIM(some_string_field); */
/* * Assume Firebird database */ $sql = $db->length(some_string_field); /* * Returns: CHAR_LEN(TRIM(some_string_field); */