Run a SELECT query by ID
@param int|string $id The id of the record you want to retrieve
@return mixed Query result
@since 1.1.4
327176
public function getOneById($id)
    {
        $id = (string)$id;

        $fields = implode(', ', $this->fields);
        $sql = 'SELECT ' . $fields . ' FROM ' . $this->table . ' WHERE ' . $this->table . '.id = :id';
        $query = $this->pdo->prepare($sql);
        $query->bindParam(':id', $id);
        $query->execute();

        return $query->fetch(PDO::FETCH_ASSOC);
    }
1370767
public function selectById($id)
	{
		$sql = "SELECT * FROM `$this->tableName` WHERE `$this->pkColName` = %d ";
		$stmt = $this->pdo->prepare(sprintf($sql, $id));
		$res = $stmt->execute();

		if ($res === false) {
			return null;
		}

		$rows = $stmt->fetchAll();

		if (count($rows) !== 1) {
			return null;
		}

		return $this->prepareEntity($rows[0]);
	}
303286
protected function get($id = null)
    {
        $this->filter();

        if ($this->eagerLoad) {
            $this->model = $this->model->with($this->eagerLoad);
        }

        if ($id) {
            return $this->model->where('id', $id)->firstOrFail();
        }

        return $this->model->get();
    }
1306946
public function getById($id)
    {
        if (isset($this->idList[$id])) {
            return $this->idList[$id];
        }

        return null;
    }
1019350
public function find($id) {
        $pri = $this->connection->getPrimaryKey();
        if ($pri && $id) {
            $data = $this->where($pri, '=', $id)->first();

            return $data;
        }
    }
1027139
public function run($id)
    {
        $model = $this->findModel($id);

        if ($this->checkAccess) {
            call_user_func($this->checkAccess, $this->id, $model);
        }

        if (!Yii::$app->adminuser->identity->is_api_user) {
            $modelClass = $this->modelClass;
            $table = $modelClass::tableName();
            $alias = Yii::$app->adminmenu->getApiDetail($modelClass::ngRestApiEndpoint());
            UserOnline::lock(Yii::$app->adminuser->id, $table, $id, 'lock_admin_edit_crud_item', ['table' => $alias['alias'], 'id' => $id, 'module' => $alias['module']['alias']]);
        }
        
        return $model;
    }
206610
public function get_from_id(int $id) {
        $records = $this->get_from_ids([$id]);
        return count($records) ? array_shift($records) : null;
    }
96072
public static function find($id) 
    {
        self::_checkLoaded();

        $pk               = self::isIgnoringCase() ? strtolower(self::getPK()) : self::getPK();
        $builder          = self::_makeBuilder();
        $builder->fields  = self::extractColumns();
        $builder->where   = self::_extractWhereConditions(array($pk=>$id));
        $builder->limit   = 1;

        $cls  = get_called_class();
        $stmt = self::executePrepared($builder, array($id));
        $data = $stmt->fetch(\PDO::FETCH_ASSOC);

        if (!$data) {
            return null;
        }
        return new $cls($data);
    }
805442
public function find($id)
    {
        $query = $this->getQuery();
        if ($this->isRestorable()) {
            $query->withTrashed();
        }

        return $query->find($id);
    }
286147
public static function findById($id)
    {
        try {
            $tableName = self::getTableName();
            $conn = self::getConnection();

            $stmt = $conn->query('SELECT * FROM '.$tableName.' WHERE id='.$id);

            return self::find($stmt);
        }
        catch(PDOException $pe) {
            return $pe->getMessage();
        }
        catch(Exception $e) {
            return $e->getMessage();
        }
    }
108846
public function load($id)
    {
        $procedure = $this->procedureFactory->createProcedure();
        $procedure->setTemplate(
            $this->loadTemplate($id)
        );

        return $procedure;
    }
433320
public function fetchById ($id)
    {
        $record = $this->query->fetchById($id);

        if ($record instanceof \stdClass) {
            $this->setRecord($record);
        } else {
            $this->record = null;
        }
    }
1206187
public function getById($id, $srid = null)
    {
        $rows = $this->getSelectQueryBuilder($srid)
            ->where($this->getUniqueId() . " = :id")
            ->setParameter('id', $id)
            ->execute()
            ->fetchAll();
        $this->prepareResults($rows, $srid);
        return reset($rows);
    }
1059444
public function run($id)
    {
        $model = $this->getModel($id);
        
        if ($model->restore()) {
            $this->addSuccessFlash();
        }

        return $this->redirect($model);
    }
318790
public function find($id)
    {
        $this->query->where($this->model->getKeyName(), $id);

        return $this->first();
    }
1036355
public function read($id)
    {
        $sql = 'SELECT ' . $this->config['dataColumn'] . ' FROM ' . $this->config['name']
            . ' WHERE ' . $this->config['primary'] . ' = ?'
            . ' AND ' . $this->config['modifiedColumn'] . ' + ' . $this->config['lifetimeColumn'] . ' >= ?';

        $result = $this->fetchOne($sql, array($id, time()));

        if (!$result) {
            $result = '';
        }

        return $result;
    }
426494
public static function find($id)
    {
        self::init();
        $query = 'SELECT * FROM ' . self::$modelTable . ' WHERE id = '.$id;
        $qb = new QueryBuilder(self::$connect, $query);
        $rows = $qb->get();
        $collection = self::makeCollection($rows);
        return !empty($collection) ? array_shift($collection) : null;
    }