Browse Source

save stored procedure code

tags/0.1.7^0
Robin Thoni 8 years ago
parent
commit
1fabbf0841
1 changed files with 6 additions and 3 deletions
  1. 6
    3
      src/Generator/LuGenerator.php

+ 6
- 3
src/Generator/LuGenerator.php View File

200
 
200
 
201
     public function getStoredProcedures()
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
 FROM information_schema.routines r
204
 FROM information_schema.routines r
205
 LEFT JOIN pg_catalog.pg_proc proc ON proc.proname = r.routine_name
205
 LEFT JOIN pg_catalog.pg_proc proc ON proc.proname = r.routine_name
206
 WHERE r.specific_schema='public'");
206
 WHERE r.specific_schema='public'");
246
             return $this->printError($spQuery, "Failed to get arguments for stored procedure " . $sp_name);
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
         $vars = array(
251
         $vars = array(
252
             "sp" => $sp,
252
             "sp" => $sp,
253
             "args" => $args
253
             "args" => $args
254
         );
254
         );
255
+        file_put_contents($spFile, $sp["prosrc"]);
255
         $this->buildTwig('sp.php', $file, $vars);
256
         $this->buildTwig('sp.php', $file, $vars);
256
     }
257
     }
257
 
258
 
313
         $dbo_dir = $this->_config["dbo"]["folder"] . "/";
314
         $dbo_dir = $this->_config["dbo"]["folder"] . "/";
314
         $model_dir = $this->_config["models"]["folder"] . "/";
315
         $model_dir = $this->_config["models"]["folder"] . "/";
315
         $sp_dir = $this->_config["sp"]["folder"] . "/";
316
         $sp_dir = $this->_config["sp"]["folder"] . "/";
317
+        $sp_src_dir = $this->_config["sp"]["folder"] . "/src/";
316
         $manager_dir = $this->_config["dataaccess"]["folder"] . "/";
318
         $manager_dir = $this->_config["dataaccess"]["folder"] . "/";
317
         $business_dir = $this->_config["business"]["folder"] . "/";
319
         $business_dir = $this->_config["business"]["folder"] . "/";
318
         $controller_dir = $this->_config["controller"]["folder"] . "/";
320
         $controller_dir = $this->_config["controller"]["folder"] . "/";
323
         $this->mkdir($dbo_dir, $mode);
325
         $this->mkdir($dbo_dir, $mode);
324
         $this->mkdir($model_dir, $mode);
326
         $this->mkdir($model_dir, $mode);
325
         $this->mkdir($sp_dir, $mode);
327
         $this->mkdir($sp_dir, $mode);
328
+        $this->mkdir($sp_src_dir, $mode);
326
         $this->mkdir($manager_dir, $mode);
329
         $this->mkdir($manager_dir, $mode);
327
         $this->mkdir($business_dir, $mode);
330
         $this->mkdir($business_dir, $mode);
328
         $this->mkdir($controller_dir, $mode);
331
         $this->mkdir($controller_dir, $mode);
376
                 $args["in"] = $this->sqlTypesToPhpTypes($args["in"]);
379
                 $args["in"] = $this->sqlTypesToPhpTypes($args["in"]);
377
                 $args["out"] = $this->sqlTypesToPhpTypes($args["out"]);
380
                 $args["out"] = $this->sqlTypesToPhpTypes($args["out"]);
378
                 $sp_model_name = LuStringUtils::stringSnakeToCamelCase($sp_name, true);
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
     }

Loading…
Cancel
Save