final public static function getObjectByQuery($query, $params=[]) {
		
		$app	= Application::getInstance();
		$db		= Database::getInstance();
		$class	= get_called_class();
		
		// run query
		$db->setQuery($query);
		$row = $db->loadObject($params);
		
		// initialize custom binds
		$customBinds = [];
		
		if (!is_a($row, 'stdClass')) {
			return NULL;
		}
			
		$binds = $class::getBinds();
		
		// get object properties from query
		$fields  = get_object_vars($row);
		
		// search for custom field names
		foreach ($fields as $field=>$value) {
			if (!array_search($field, $binds)) {
				$customBinds[Utilities::getCamelCase($field)] = $field;
			}
		}
		
		$object = new $class($row);
		
		// populate custom properties
		foreach ($customBinds as $customProp=>$customField) {
			$object->$customProp = $row->$customField;
		}
			
		// turn on loaded-from-db flag
		$object->loadedFromDb = TRUE;
			
		$app->logEvent('Loaded a ' . $class . ' object' . (count($customBinds) ? ' with custom fields ' . implode(',', $customBinds) : ''));
		
		return $object;
		
	}
final public static function getObjectByQuery($query, $params=[]) {
		
		$app	= Application::getInstance();
		$db		= Database::getInstance();
		$class	= get_called_class();
		
		// run query
		$db->setQuery($query);
		$row = $db->loadObject($params);
		
		// initialize custom binds
		$customBinds = [];
		
		if (!is_a($row, 'stdClass')) {
			return NULL;
		}
			
		$binds = $class::getBinds();
		
		// get object properties from query
		$fields  = get_object_vars($row);
		
		// search for custom field names
		foreach ($fields as $field=>$value) {
			if (!array_search($field, $binds)) {
				$customBinds[Utilities::getCamelCase($field)] = $field;
			}
		}
		
		$object = new $class($row);
		
		// populate custom properties
		foreach ($customBinds as $customProp=>$customField) {
			$object->$customProp = $row->$customField;
		}
			
		// turn on loaded-from-db flag
		$object->loadedFromDb = TRUE;
			
		$app->logEvent('Loaded a ' . $class . ' object' . (count($customBinds) ? ' with custom fields ' . implode(',', $customBinds) : ''));
		
		return $object;
		
	}
final public static function getObjectByQuery ( $ query , $ params = [ ] ) { $ app = Application :: getInstance ( ) ; $ db = Database :: getInstance ( ) ; $ class = get_called_class ( ) ; // run query $ db -> setQuery ( $ query ) ; $ row = $ db -> loadObject ( $ params ) ; // initialize custom binds $ customBinds = [ ] ; if ( ! is_a ( $ row , 'stdClass' ) ) { return NULL ; } $ binds = $ class :: getBinds ( ) ; // get object properties from query $ fields = get_object_vars ( $ row ) ; // search for custom field names foreach ( $ fields as $ field => $ value ) { if ( ! array_search ( $ field , $ binds ) ) { $ customBinds [ Utilities :: getCamelCase ( $ field ) ] = $ field ; } } $ object = new $ class ( $ row ) ; // populate custom properties foreach ( $ customBinds as $ customProp => $ customField ) { $ object -> $ customProp = $ row -> $ customField ; } // turn on loaded-from-db flag $ object -> loadedFromDb = TRUE ; $ app -> logEvent ( 'Loaded a ' . $ class . ' object' . ( count ( $ customBinds ) ? ' with custom fields ' . implode ( ',' , $ customBinds ) : '' ) ) ; return $ object ; }
Get one object of inherited class as result of the query run.

@param	string	Query to run.
@param	array	Optional bind parameters for query.

@return	mixed|NULL
Get one object of inherited class as result of the query run .