Back to InstallerScript class

Method getInstances

public array
getInstances
(mixed $isModule)
Gets each instance of a module in the #__modules table
Parameters
  • bool $isModule True if the extension is a module as this can have multiple instances
Returns
  • array An array of ID's of the extension
Since
  • 3.6

Method getInstances - Source code

/**
 * Gets each instance of a module in the #__modules table
 *
 * @param   boolean  $isModule  True if the extension is a module as this can have multiple instances
 *
 * @return  array  An array of ID's of the extension
 *
 * @since   3.6
 */
public function getInstances($isModule)
{
    $extension = $this->extension;
    $db = Factory::getDbo();
    $query = $db->getQuery(true);
    // Select the item(s) and retrieve the id
    $query->select($db->quoteName('id'));
    if ($isModule) {
        $query->from($db->quoteName('#__modules'))->where($db->quoteName('module') . ' = :extension');
    } else {
        $query->from($db->quoteName('#__extensions'))->where($db->quoteName('element') . ' = :extension');
    }
    $query->bind(':extension', $extension);
    // Set the query and obtain an array of id's
    return $db->setQuery($query)->loadColumn();
}