orma
1.0.0
composer require sensorario/orma
프로젝트 루트에 vendor/sensorario/orma/public/index.php 복사하세요. SQLite는 설치가 필요하지 않습니다. Postgres는 docker: vendor/sensorario/orma/docker-compose.yaml 과 함께 사용할 수 있습니다.
행복한 코딩
Postgres 데이터는 프로젝트 내부의 도커 머신을 참조합니다.
$ config = [
' postgresql ' => [
' dns ' => ' pgsql:host=database;dbname=your_database_name ' ,
' username ' => ' your_username ' ,
' password ' => ' your_password ' ,
],
' sqlite ' => [
' dns ' => ' sqlite:./erdatabase ' ,
],
' db ' => ' postgresql ' ,
' db ' => ' sqlite ' ,
];
$ pdo = new PDO (
$ config [ $ config [ ' db ' ]][ ' dns ' ],
$ config [ $ config [ ' db ' ]][ ' username ' ],
$ config [ $ config [ ' db ' ]][ ' password ' ],
); $ orma = new Orma ( $ pdo , match ( $ driver ) {
' sqlite ' => new SQLiteDriver ,
' postgresql ' => new PostgreSQLDriver ,
}); $ orma ( $ table )-> createTable (); $ orma -> addColumn ( $ column ); $ orma -> insert ([ ' id ' => 42 , ]); $ orma -> delete ([ ' id ' => 42 , ]); $ orma -> update ([ ' foo ' => ' bar ' , ], [ ' id ' => 42 , ]);추신. 이 저장소는 단지 재미를 위해 만들어졌습니다.