Check if a record exists for the given id

@param Model $model
@param id
@return mixed
977038
public function existsAndNotDeleted(Model $model, $id) {
		if ($id === null) {
			$id = $model->getID();
		}
		if ($id === false) {
			return false;
		}
		$exists = $model->find('count', array('conditions' => array($model->alias . '.' . $model->primaryKey => $id)));
		return ($exists ? true : false);
	}
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.');
        }
    }
1207567
protected function findModel($id)
    {
        if (($model = TermType::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
        }
    }
812442
protected function findOrFail($id)
    {
        $model = $this->model;
        if ($this->withTrashed()) {
            return $model::withTrashed()->findOrFail($id);
        } else {
            return $model::findOrFail($id);
        }
    }
451548
public function exists($id) {
        return (bool) $this->select()->where($this->getPrimaryKey(), $id)->count();
    }
952750
public function getById($id)
    {
        $modelResult = $this->getRequest()->request(
            'GET',
            $this->getRequestUrl(sprintf('models/%s', $id))
        );

        return $this->getModelFromResult($modelResult);
    }
300038
public static function getLock($id) {

        $model = get_called_class();
        /* @var $t Record */
        $t = new $model;
        $select = DB::select($t->getTable())->where($t->getPkField(), $id)->lock()->setRecord($model);
        Event::trigger('record_before_select', [$t, $select]);
        $data = $select->find();
        return $data;
    }
1267003
protected function checkExists($id)
    {
        $filter = array(
            'fields' => array(
                array(
                    'field' => 'id',
                    'compare' => '=',
                    'value' => $id,
                ),
            ),
        );
        $exists = $this->rubric->count($filter);
        return $exists?true:false;
    }
521470
private function find($id): ?Model
    {
        try {
            return $this->repository->findOrFail($id);
        } catch (ModelNotFoundException $exception) {
            return null;
        }
    }
803978
public function deleteById($model, $id)
    {
        if ($id instanceof Collection)
            $id = $id->toArray();

        $method = 'unlink';

        $result = $this->call($model, $method, [$id]);

        return $this->makeResponse($result, 0);
    }
339506
public function findModel($id = null)
    {
        if ($id === null) {
            return new Item();
        }
        if (($model = Item::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException(Yii::t('modules/page', 'The requested page does not exist.'));
        }
    }
1018992
public function getName(Model $model, $id = null) {
		if (empty($id) || empty($model->displayField)) {
			return false;
		}
		if (is_array($id)) {
			if (!isset($id[$model->alias][$model->displayField])) {
				return false;
			}

			$result = $id[$model->alias][$model->displayField];
		} else {
			$model->id = $id;
			$result = $model->field($model->displayField);
		}

		return $result;
	}
640909
def get_model(self, model, model_id):
        
        return self._store.find_record(self._get_model_class(model), int(model_id))
540237
public function recordCache($model, $id) {
        $cache_key = "record_" . $model . $id;
        $data = Cache::get($cache_key);
        if ($data) {
            Log::debug("命中缓存" . $model . " " . $id, 'cache');
            /* @var $record Record */
            $record = new $model;
            $record->fromDbData($data);
            return $record;
        }
        return null;
    }
38092
public function findRecord($id)
    {
        if (is_object($id)) {
            return $id;
        }

        if (is_numeric($id) or $this->shouldBeNumber($id)) {
            return $this->findById($id);
        }

        if (is_string($id)) {
            return $this->findByIdentifier($id);
        }
    }
639670
public function exists($model, $query)
    {
        //
        $params = [];

        //
        $whereArray = [];

        //
        if (isset($query['where'])) {
            $whereArray[] = $query['where'];
            unset($query['where']);
        }

        //
        $schema = $this->getFields($model);

        foreach ($schema as $field) {
            if (!isset($query[$field])) {
                continue;
            }
            $value = $query[$field];
            $token = ':'.$field;
            $params[$token] = $value;
            $whereArray[] = "`{$field}` = {$token}";
        }

        $where = count($whereArray) > 0
               ? 'WHERE '.implode(' AND ', $whereArray) : '';

        $table = $this->getPrefix($model);
        $sql = "SELECT * FROM `{$table}` {$where} LIMIT 1";
        $row = $this->getRow($sql, $params);

        return $row;
    }
1003972
public function findModel($id)
    {
        if($this->_model === null) 
        {
            if($this->_model = $id ? Author::findOne($id) : null) 
            {
                return $this->_model;
            } else {
                throw new NotFoundHttpException(Module::t('core', 'The requested model does not exist.'));
            }
        }
    }