src/Database/ORM/Traits/QueryBuilding.php
/**
	 * Gets a model instance by the primary key value.
	 *
	 * @param mixed $primaryKey
	 * @return static
	 */
Gets a model instance by the primary key value.
@param mixed $primaryKey
@return static
Gets a model instance by the primary key value . @param mixed $primaryKey @return static
public static function find($primaryKey) {
		$o = (new static);
		$connection = DB::connection($o->getConnection());
		$cache = $connection->cache()->getModelInstance(get_class($o), $primaryKey);
		if (!is_null($cache)) {
			return $cache;
		}
		$builder = $o->createSelectQuery($primaryKey)->limit(1);
		$builder->setModel(get_class($o));
		$row = $builder->first();
		if (!is_null($row)) {
			$connection->cache()->saveModelInstance($row);
		}
		return $row;
	}
public static function find ( $ primaryKey ) { $ o = ( new static ) ; $ connection = DB :: connection ( $ o -> getConnection ( ) ) ; $ cache = $ connection -> cache ( ) -> getModelInstance ( get_class ( $ o ) , $ primaryKey ) ; if ( ! is_null ( $ cache ) ) { return $ cache ; } $ builder = $ o -> createSelectQuery ( $ primaryKey ) -> limit ( 1 ) ; $ builder -> setModel ( get_class ( $ o ) ) ; $ row = $ builder -> first ( ) ; if ( ! is_null ( $ row ) ) { $ connection -> cache ( ) -> saveModelInstance ( $ row ) ; } return $ row ; }
Gets a model instance by the primary key value.
Gets a model instance by the primary key value .
// Cache the new model instance