You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sp.php.twig 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. {{ "<?php" }}
  2. namespace App\Http\DataAccess\SP;
  3. use Luticate\Utils\LuSpModel;
  4. use Illuminate\Support\Facades\DB;
  5. class {{ sp.sp_name.camel_upper }} extends LuSpModel {
  6. protected static function damToDbo($dam)
  7. {
  8. if (is_null($dam))
  9. return null;
  10. $dbo = new {{ sp.sp_name.camel_upper }}();
  11. {% for arg in args.out %}
  12. $dbo->set{{ arg.name.camel_upper }}($dam->{{ arg.name.as_it }});
  13. {% endfor %}
  14. return $dbo;
  15. }
  16. public static function execute({% for arg in args.in %}${{ arg.name.as_it }}{{ loop.last ? "" : ", " }}{% endfor %})
  17. {
  18. $values = DB::select('SELECT * FROM {{ sp.sp_name.as_it }}({% for arg in args.in %}?{{ loop.last ? "" : ", " }}{% endfor %})', array({% for arg in args.in %}${{ arg.name.as_it }}{{ loop.last ? "" : ", " }}{% endfor %}));
  19. {% if sp.proretset %}
  20. $dboValues = array();
  21. foreach ($values as $value)
  22. $dboValues[] = self::damToDbo($value);
  23. return $dboValues;
  24. {% else %}
  25. return self::damToDbo($values[0]);
  26. {% endif %}
  27. }
  28. {% for arg in args.out %}
  29. /**
  30. * @var {{ arg.data_type.php.as_it }}
  31. */
  32. protected $_{{ arg.name.camel_lower }};
  33. public function get{{ arg.name.camel_upper }}()
  34. {
  35. return $this->_{{ arg.name.camel_lower }};
  36. }
  37. public function set{{ arg.name.camel_upper }}($value)
  38. {
  39. $this->_{{ arg.name.camel_lower }} = $value;
  40. }
  41. {% endfor %}
  42. }