From 9231fb6d11f965e737ba810f82aefcd73d1ab5f1 Mon Sep 17 00:00:00 2001 From: Francois Faubert Date: Thu, 6 Oct 2016 15:49:25 -0400 Subject: [PATCH] Its more logical to create the model first when trying to understand how it works --- README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 47a0613..380a8a5 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,17 @@ You models will then feed an instance of the service class when a `query()` invo In this example we will create a Strata Model named 'Rates' that connects to an external MySQL database using a custom service. -First start by creating a file under `~/src/Model/Service/` named `RatesService.php`. -The file should contain connection information as well optional pre-formatted queries. It also has the mandate of returning `RateEntity` elements upon each queries' `fetch()`. +First, create a new `Rate` Model using Strata's `generate` command. + +~~~ bash +$ ./strata generate model rate +~~~ + + +Then manually create a new connection service class under `~/src/Model/Service/` named `RatesService.php`. + +The file should contain connection information as well optional pre-formatted queries. It also has the job of returning `RateEntity` elements upon each queries' `fetch()`. ~~~ php select("r.*") @@ -63,7 +71,7 @@ class RatesService extends MysqlConnector { ->fetch(); } - public function getWithCategories() + public function findWithCategories() { return $this ->select("r.*") @@ -75,13 +83,6 @@ class RatesService extends MysqlConnector { ~~~ -Secondly, create a new `Rate` Model using Strata's `generate` command. - -~~~ bash -$ ./strata generate model rate -~~~ - - Finally configure the class to use the new service as query adapter. ~~~ php