Przeglądaj źródła

save stored procedure code

tags/0.1.7^0
Robin Thoni 8 lat temu
rodzic
commit
1fabbf0841
1 zmienionych plików z 6 dodań i 3 usunięć
  1. 6
    3
      src/Generator/LuGenerator.php

+ 6
- 3
src/Generator/LuGenerator.php Wyświetl plik

@@ -200,7 +200,7 @@ WHERE table_type = 'BASE TABLE' AND table_schema NOT IN ('pg_catalog', 'informat
200 200
 
201 201
     public function getStoredProcedures()
202 202
     {
203
-        $spQuery = $this->_pdo->prepare("SELECT r.routine_name AS sp_name, r.data_type AS data_type, proc.proretset AS proretset
203
+        $spQuery = $this->_pdo->prepare("SELECT r.routine_name AS sp_name, r.data_type AS data_type, proc.proretset AS proretset, proc.prosrc AS prosrc
204 204
 FROM information_schema.routines r
205 205
 LEFT JOIN pg_catalog.pg_proc proc ON proc.proname = r.routine_name
206 206
 WHERE r.specific_schema='public'");
@@ -246,12 +246,13 @@ ORDER BY parameters.ordinal_position;");
246 246
             return $this->printError($spQuery, "Failed to get arguments for stored procedure " . $sp_name);
247 247
     }
248 248
 
249
-    public function generateSp($sp, $args, $file)
249
+    public function generateSp($sp, $args, $file, $spFile)
250 250
     {
251 251
         $vars = array(
252 252
             "sp" => $sp,
253 253
             "args" => $args
254 254
         );
255
+        file_put_contents($spFile, $sp["prosrc"]);
255 256
         $this->buildTwig('sp.php', $file, $vars);
256 257
     }
257 258
 
@@ -313,6 +314,7 @@ ORDER BY parameters.ordinal_position;");
313 314
         $dbo_dir = $this->_config["dbo"]["folder"] . "/";
314 315
         $model_dir = $this->_config["models"]["folder"] . "/";
315 316
         $sp_dir = $this->_config["sp"]["folder"] . "/";
317
+        $sp_src_dir = $this->_config["sp"]["folder"] . "/src/";
316 318
         $manager_dir = $this->_config["dataaccess"]["folder"] . "/";
317 319
         $business_dir = $this->_config["business"]["folder"] . "/";
318 320
         $controller_dir = $this->_config["controller"]["folder"] . "/";
@@ -323,6 +325,7 @@ ORDER BY parameters.ordinal_position;");
323 325
         $this->mkdir($dbo_dir, $mode);
324 326
         $this->mkdir($model_dir, $mode);
325 327
         $this->mkdir($sp_dir, $mode);
328
+        $this->mkdir($sp_src_dir, $mode);
326 329
         $this->mkdir($manager_dir, $mode);
327 330
         $this->mkdir($business_dir, $mode);
328 331
         $this->mkdir($controller_dir, $mode);
@@ -376,7 +379,7 @@ ORDER BY parameters.ordinal_position;");
376 379
                 $args["in"] = $this->sqlTypesToPhpTypes($args["in"]);
377 380
                 $args["out"] = $this->sqlTypesToPhpTypes($args["out"]);
378 381
                 $sp_model_name = LuStringUtils::stringSnakeToCamelCase($sp_name, true);
379
-                $this->generateSp($sp, $args, $sp_dir . $sp_model_name . ".php");
382
+                $this->generateSp($sp, $args, $sp_dir . $sp_model_name . ".php", $sp_src_dir . $sp_name . ".sql");
380 383
             }
381 384
         }
382 385
     }

Ładowanie…
Anuluj
Zapisz