라라벨(LARAVEL)

Jiwon·2022년 6월 13일
0

Web

목록 보기
11/11

라라벨(LARAVEL)

모델-뷰-컨트롤러(MVC) 아키텍쳐 패턴을 따르는 프레임워크
PHP 프레임워크이다.

모델-뷰-컨트롤러 패턴에는 많은 기능들이 내장되어 있음.
( 인증 시스템, 페이지 처리, 엘로퀀트, ORM, 데이터베이스 마이그레이션 등 )

객체지향 라이브러리

명령 줄 인터페이스

라라벨의 템플릿 엔진
-> 소스 템플릿 안에 있는 코드를 처리한 다음, 그 결과물을 해당하는 텍스트 파일 또는 프로세스에 전달하기 위해 템플릿 엔진을 사용해야 한다.
라라벨의 내장 템플릿 엔진은 템플릿들을 평범한 PHP 코드로 컴파일하고, 성능 개선을 위해서 캐싱(caching)을 함으로써 뷰를 생성하는 작업 수행.
오버헤드를 추가하지 않고 템플릿을 데이터 모델과 결합 가능

효율적인 ORM과 데이터베이스 관리
--> 모델(model)을 제작하고 커스터마이징(customizing)하는 작업이 더욱 자연스러워진다는 것

효과적인 단위 테스트를 위한 적절한 지원
--> PHPUnit을 통한 단위 테스트 진행

라라벨 sql 쿼리 문법

한 테이블에서 모든 행 가져오기

$users = DB::table('users') -> get();

foreach ($users as $user)
{
	var_dump($user->name);
}

테이블에서 하나의 결과 가져오기

$user = DB::table('users')->where('name', 'John') -> first();

var_dump($user->name);

한개의 행에서 하나의 컬럼만을 가져오기

$name = DB::table('users')->where('name', 'John')->pluck('name');

컬럼 값들의 리스트 가져오기

$roles = DB::table('roles')->lists('title');

이미 있는 쿼리에 select 문 추가하기

$query = DB::table('users')->select('name');
$users = $query->addSelect('age')->get();

Where 구문 사용

$users = DB::table('users')->where('votes', '>', 100)->get();

Or 구문

$users = DB::table('users')
			->where('votes', '>', 100)
            ->orWhere('name', 'John')
            ->get();

WhereBetween 사용

$users = DB::table('users')
			->where('votes', '>', 100)
            ->orWhere('name', 'John')
            ->get();

WhereBetween 사용

$users = DB::table('users')
			->whereBetween('votes', [1,100])->get();

WhereNotBetween 사용

$users = DB::table('users')
			->whereNotBetween('votes', [1,100])->get();

배열로 wehreIn 사용

$users = DB::table('users')
			->whereIn('id', [1,2,3])->get();
$users = DB::table('users')
			->whereNotIn('id', [1,2,3])->get();

더 많은 쿼리문법은 아래 참고사이트 참고 바람.
https://gdpark.tistory.com/120

작동원리

https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=sksk3479&logNo=221056398790


라라벨이란? 참고사이트
https://blog.wishket.com/%EC%B5%9C%EA%B3%A0%EC%9D%98-php%ED%94%84%EB%A0%88%EC%9E%84%EC%9B%8C%ED%81%AC-%EB%9D%BC%EB%9D%BC%EB%B2%A8laravel-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0/

profile
과연 나는 ?

0개의 댓글