CommonDBTM::getFromDBByQuery PHP Method

getFromDBByQuery() public method

Retrieve an item from the database by query. The query must include the WHERE keyword. Thus, we can replace "WHERE" to make complex SQL JOINED queries (for instance, see User::getFromDBbyEmail()).
public getFromDBByQuery ( $query ) : true
$query the "WHERE" or "JOIN" part of the SQL query
return true if succeed else false
    function getFromDBByQuery($query)
    {
        global $DB;
        // Make new database object and fill variables
        if (empty($query)) {
            return false;
        }
        $query = "SELECT `" . $this->getTable() . "`.*\n                FROM `" . $this->getTable() . "`\n                {$query}";
        if ($result = $DB->query($query)) {
            if ($DB->numrows($result) == 1) {
                $this->fields = $DB->fetch_assoc($result);
                $this->post_getFromDB();
                return true;
            }
        }
        return false;
    }
CommonDBTM