Find all the post records associated with a tag

@param  int    $id     id
@return array
10798
public function countAllPostsThatHaveUserId($id)  {
        // How many posts did this user create (created_by)?
        $results = DB::table('posts')->where('created_by', '=', $id)->get();

        if ( (count($results)) == 0 || (empty($results)) ) {
            $created_by = 0;
        } else {
            $created_by = count($results);
        }

        // How many posts did this user update (updated_by)?
        $results = DB::table('posts')->where('updated_by', '=', $id)->get();

        if ( (count($results)) == 0 || (empty($results)) ) {
            $updated_by = 0;
        } else {
            $updated_by = count($results);
        }

        return ['created_by' => $created_by, 'updated_by' => $updated_by];
    }
661366
public function getFullHostById($id)
    {
        foreach ($this->hosts as $host => $parameters) {
            if (!isset($parameters['id']) || $parameters['id'] !== $id) {
                continue;
            }

            return $parameters;
        }

        return null;
    }
752542
public function exportById($id): array
    {
        $section = Craft::$app->sections->getSectionById((int) $id);

        return $this->export($section);
    }
624522
function instance($id): array
    {
        return collect($this->find($id))
            // Filter model attributes on actual form fields
            ->only($this->getDataKeys())
            ->all();
    }
678818
public function exportById($id): array
    {
        $site = Craft::$app->sites->getSiteById((int) $id);

        return $this->export($site);
    }
564739
public function getTagTitlesByPostId($postId)
    {
        // Grab the tag ID's from the post_tag table
        $post_tags = DB::table('post_tag')
            ->where('post_id', '=', $postId)
            ->get()
        ;

        // if there are no tags associated with this post, then return emptiness
        if (empty($post_tags)) {
            return $post_tags;
        }


        // ah, there are tags associated with the post

        // initialize the array that will be returned
        $tagTitles = [];

        // go through each tag_id and grab the tag's title
        foreach ($post_tags as $post_tag) {

            $tag = DB::table('tags')
                ->select('title')
                ->where('id', '=', $post_tag->tag_id)
                ->first();

            $tagTitles[] = $tag->title;
        }

        return $tagTitles;
    }
753560
function get_record_groups($id)
    {
        $results = array();

        if (!$this->groups) {
            return $results;
        }

        $sql_result = $this->db->query(
            "SELECT cgm.`contactgroup_id`, cg.`name` "
            . " FROM " . $this->db->table_name($this->db_groupmembers, true) . " AS cgm"
            . " LEFT JOIN " . $this->db->table_name($this->db_groups, true) . " AS cg"
                . " ON (cgm.`contactgroup_id` = cg.`contactgroup_id` AND cg.`del` <> 1)"
            . " WHERE cgm.`contact_id` = ?",
            $id
        );

        while ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) {
            $results[$sql_arr['contactgroup_id']] = $sql_arr['name'];
        }

        return $results;
    }
1278420
public function getTags($id = false, array $array = [], $section, $modelClass = __CLASS__)
    {
        $tags = [$section, $modelClass];

        if ($id) {
            $tags[] = $modelClass . 'id' . $id;
        }

        if ($array) {
            foreach ($array as $relation) {
                $tags[] = $relation;
            }
        }

        return $tags;
    }
682157
public function getRelatedPosts($id, $category_id)
	{
		$items = array();
        $criteria = Content::model()->getBaseCriteria()
                    ->addCondition('category_id = :category_id')
                    ->addCondition('id != :id')
                    ->addCondition('type_id = 2')
                    ->addCondition('password = ""');
        $criteria->order = 'published DESC';
        $criteria->limit = 5;
        $criteria->params = array(':id' => $id, ':category_id' => $category_id);

        $related = Content::model()->findAll($criteria);

		 foreach ($related as $v)
		 	$items[] = array('label' => $v->title, 'url' => Yii::app()->createAbsoluteUrl($v->slug), 'itemOptions' => array('id' => $v->id, 'published' => $v->published));

        return $items;
	}
1051042
public function getSubs($id)
	{
		$target = Member::find($id);

		$department_ids = $this->getSubDepartments($target->department);
		$position_ids = $this->getSubPositions($target->position);
		
		$recs = Member::whereIn('department', $department_ids)
		              ->whereIn('position', $position_ids)
		              ->where('id', '>', 1)
		              ->where('state', 0)
              		  ->where('new', 1)
		              ->where('private', 1)
		              ->where('show', 0)
		              ->get();

		$arr = [];             
		if(count($recs)){
			foreach ($recs as $rec) {
				$arr[] = $rec->work_id;
			}
			return $arr;
		}

	}
115453
public function parseMeta($id)
	{
		$items = array();
		$data = ContentMetadata::model()->findAllByAttributes(array('content_id' => $id));
		foreach ($data as $element)
			$items[$element->key] = $this->isJson($element->value) ? CJSON::decode($element->value) : $element->value;
		
		return $items;
	}
1043852
public function find($id)
    {
        $resultSet = $this->findAllBy(array(
            $this->getIdColumn() => $id,
        ));

        if (count($resultSet)) {
            return $resultSet[0];
        }

        throw new \DomainException(
            sprintf(
                '%s record not found by %s %s',
                $this->getTableName(),
                $this->getIdColumn(),
                $id
            )
        );
    }
1146003
public function exportById($id): array
    {
        $tagGroup = Craft::$app->tags->getTagGroupById((int) $id);

        return $this->export($tagGroup);
    }
971017
public function actionViewAjax($id)
    {
        $model = Article::findOne($id);
        if( $model === null ) throw new NotFoundHttpException("None exists article id");
        return [
            'likeCount' => (int)$model->getArticleLikeCount(),
            'scanCount' => $model->scan_count * 100,
            'commentCount' => $model->comment_count,
        ];
    }
389365
protected function getPost($id)
    {
        $post = $this->postManager->find($id);

        if (null === $post) {
            throw new NotFoundHttpException(sprintf('Post (%d) not found', $id));
        }

        return $post;
    }
1103027
public function findJournalForId($id)
    {
        $dql = '
            SELECT    j,p
            FROM      %s j
            LEFT JOIN j.postings p
            WHERE     j.id = :id
            AND       j.organization = :organization
        ';

        return $this->em
            ->createQuery(sprintf($dql, $this->journalFqcn))
            ->setParameter('id', $id)
            ->setParameter('organization', $this->oh->getOrganization())
            ->getSingleResult()
        ;
    }
804965
public function index($id = 0) {
		$post = $this->request->_getPost();
		$buffers = [];
		foreach ($post as $request) {
			$this->prepareGetRequest($request);
			$this->controllerService->callController($request['controller'], $request['method'], $request['id'], $request['params']);
			$buffer = $this->response->getBuffer();
			$buffer['requestid'] = $request['requestid']; // unique id
			$buffers[] = $buffer;
			$this->response->clear();
		}
		$this->response->setResponse('Multiple', $buffers);
		return true;

    }