What are the potential pitfalls of using PHP for database queries in Joomla components like Breezingforms?

Potential pitfalls of using PHP for database queries in Joomla components like Breezingforms include vulnerability to SQL injection attacks if input data is not properly sanitized, potential performance issues if queries are not optimized, and difficulties in maintaining and updating the code if queries are scattered throughout the component. To mitigate these risks, it is recommended to use Joomla's built-in database API for executing queries, which handles input sanitization and query optimization automatically.

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('id'))
      ->from($db->quoteName('#__tablename'))
      ->where($db->quoteName('column') . ' = ' . $db->quote($value));
$db->setQuery($query);
$results = $db->loadObjectList();