Search database for where the module is used
@param  integer $id Module id
@return array       List of pages where the module is used
182276
public static function getModuleUsage($id, $limit = false)
    {
        global $wpdb;

        // Normal modules
        $query = "
            SELECT
                {$wpdb->postmeta}.post_id,
                {$wpdb->posts}.post_title,
                {$wpdb->posts}.post_type
            FROM {$wpdb->postmeta}
            LEFT JOIN
                {$wpdb->posts} ON ({$wpdb->postmeta}.post_id = {$wpdb->posts}.ID)
            WHERE
                {$wpdb->postmeta}.meta_key = 'modularity-modules'
                AND ({$wpdb->postmeta}.meta_value REGEXP '.*\"postid\";s:[0-9]+:\"{$id}\".*')
                AND {$wpdb->posts}.post_type != 'revision'
            ORDER BY {$wpdb->posts}.post_title ASC
        ";

        $modules = $wpdb->get_results($query, OBJECT);

        // Shortcode modules
        $query = "
            SELECT
                {$wpdb->posts}.ID AS post_id,
                {$wpdb->posts}.post_title,
                {$wpdb->posts}.post_type
            FROM {$wpdb->posts}
            WHERE
                ({$wpdb->posts}.post_content REGEXP '([\[]modularity.*id=\"{$id}\".*[\]])')
                AND {$wpdb->posts}.post_type != 'revision'
            ORDER BY {$wpdb->posts}.post_title ASC
        ";

        $shortcodes = $wpdb->get_results($query, OBJECT);

        $result = array_merge($modules, $shortcodes);

        if (is_numeric($limit)) {
            if (count($result) > $limit) {
                $sliced = array_slice($result, $limit);
            } else {
                $sliced = $result;
            }

            return (object) array(
                'data' => $sliced,
                'more' => (count($result) > 0 && count($sliced) > 0) ? count($result) - count($sliced) : 0
            );
        }

        return $result;
    }
771513
public function findRenderList( $id = null )
    {
        $platform = $this->getDbAdapter()
                         ->getPlatform();

        $columns = $this->getSelectColumns();
        $columns['_depth'] = new Sql\Expression( '(' .
            $this->sql( null )
                 ->select( array( 'parent' => static::$tableName ) )
                 ->columns( array(
                     new Sql\Expression( 'COUNT(*)' )
                 ) )
                 ->where( array(
                     new Sql\Predicate\Expression(
                         $platform->quoteIdentifierChain( array( static::$tableName, 'left' ) ) .
                         ' BETWEEN ' . $platform->quoteIdentifierChain( array( 'parent', 'left' ) ) .
                             ' AND ' . $platform->quoteIdentifierChain( array( 'parent', 'right' ) )
                     ),
                 ) )
                 ->getSqlString( $platform ) .
        ')' );

        $select = $this->select( $columns )
                       ->order( 'left' );

        if ( null !== $id )
        {
            $select->join( array( 'parent' => self::$tableName ),
                           '( ' . self::$tableName . '.left BETWEEN parent.left AND parent.right ) ',
                           array() )
                   ->where( array( 'parent.id' => $id ) );
        }

        /* @var $result \Zend\Db\Adapter\Driver\ResultInterface */

        $return = array();
        $result = $this->sql()
                       ->prepareStatementForSqlObject( $select )
                       ->execute();

        foreach ( $result as $row )
        {
            $depth = (int) $row['_depth'];
            unset( $row['_depth'] );
            $return[] = array( $depth, $this->selected( $row ) );
        }

        return $return;
    }
816975
public function get_shared(string $id): ?array
  {
    if ( bbn\str::is_uid($id) ){
      return $this->db->rselect_all($this->class_table, [
        $this->fields['id'],
        $this->fields['id_user'],
        $this->fields['id_group']
      ], [
        $this->fields['id_alias'] => $id
      ]);
    }
    return null;
  }
507030
public function getById($id)
    {
        $database = DatabaseLayer::getInstance();
        $select = $database->select($this->getTableName(), $this->getTableAlias());
        $select->fields($this->getTableAlias());
        $select->condition($this->getIDField(), $id);
        $results = $select->execute(get_called_class());
        $result = end($results);
        return $result;
    }
239342
protected function findModel($id)
    {
        $class = $this->modelClass;
        if (($model = $class::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
328579
public function get(string $id = null): array
    {
        if ($this->has($id)) {
            return $this->cache[$id];
        }

        return [];
    }
266402
public function actionIndex($page = 1, $id = 0)
    {
        $searchModel = $this->module->model('UserSearch');
        $params = Yii::$app->request->queryParams;
        $dataProvider = $searchModel->search($params);

        $pager = $dataProvider->getPagination();
        $pager->pageSize = intval($this->module->params['pageSizeAdmin']);
        $pager->totalCount = $dataProvider->getTotalCount();

        // page number correction
        $maxPage = ceil($pager->totalCount / $pager->pageSize);
        if ($page > $maxPage) {
            $pager->page = $maxPage - 1;
        } else {
            $pager->page = $page - 1; //! from 0
        }

        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
            'currentId'    => $id,
        ]);
    }
1304241
public function index($id)
    {
        $this->authorize('readList', Block::class);
        $input  = $this->validator->validate('list');
        $params = $this->processor->process($input)->getProcessedFields();
        $block  = $this->repository->getById($id);
        if (!empty($block)) {
            $results = $this->repository->getTranslations(
                $block,
                $params['filter'],
                $params['orderBy'],
                $params['page'],
                $params['perPage']
            );
            return $this->respondWithSuccess($results, new BlockTranslationTransformer);
        } else {
            return $this->respondNotFound();
        }
    }
483688
public function getModule($id)
    {
        foreach ($this->registry->getMap() as $module) {
            if ($module['id'] == $id) {
                return $this->loadModule($module);
            }
        }
        return null;
    }
986494
public static function findAvailableModuleById($id)
    {
        $availableModels = static::findAvailableModules();
        return array_key_exists($id, $availableModels) ? $availableModels[$id] : null;
    }
556192
public function lists($id = null)
    {
        if ($id !== null) {
            $this->setId($id);
        }

        return $this->getList();
    }
824732
public function where_id_is($id)
        {
            return (Arrays::is($this->_getIdColumnName())) ?
                $this->where($this->_getCompoundIdColumnValues($id), null) :
                $this->where($this->_getIdColumnName(), $id);
        }
694280
public function getContentTags($id)
    {
        $items = array();
        $tags = Content::model()->findByPk($id)->getTags();
        foreach ($tags as $item)
            $items[] = array('label' => $item, 'url' => Yii::app()->createUrl('/search?q=' . $item));

        return $items;
    }
137992
public function findByRoleID($id)
    {
        $usersWithRepo = [];
        $users = $this->model->all();

        foreach ($users as $user) {
            if ($user->roles->first()->id == $id) {
                $usersWithRepo[] = $user;
            }
        }

        return $usersWithRepo;
    }
338462
public function findById($id)
    {
        $queryBuilder = $this->createQueryBuilder('a')
            ->addSelect('domains')
            ->leftJoin('a.domains', 'domains')
            ->where('a.id = :id');

        $query = $queryBuilder->getQuery();
        $query->setParameter('id', $id);

        return $query->getSingleResult();
    }
1026549
public function findAll($id)
    {
        $result = array();
        $root = $this->findById($id);

        if ($root !== false) {
            $result = array_merge($result, array($root));
        }

        return array_merge($result, $this->findParentNodesByChildId($id));
    }
250731
public function getmodule($id){
		if(!$db=BFactory::getDBO()){
			return false;
			}
		$qr='SELECT * from `soft_modules_rules` where id='.$id;
		$q=$db->Query($qr);
		if(empty($q)){
			return $modules;
			}
		while($l=$db->fetch($q)){
			$id=(int)$l['id'];
			$module=new BSoftModule();
			$module->load($l);
			}
		return $module;
		}