hafijul233 /
ci-recharge
| 1 | <?php namespace {namespace}\Database\Seeds; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 2 | |||
| 3 | use CodeIgniter\Database\Seeder; |
||
| 4 | use ReflectionException; |
||
| 5 | |||
| 6 | /** |
||
| 7 | * Short description of this class usages |
||
| 8 | * |
||
| 9 | * @class {name} |
||
| 10 | * @generated_by CI-Recharge |
||
| 11 | * @package {namespace} |
||
| 12 | * @extend Seeder |
||
| 13 | * @created_at {created_at} |
||
| 14 | */ |
||
| 15 | |||
| 16 | class {name} extends Seeder |
||
| 17 | { |
||
| 18 | public function run() |
||
| 19 | { |
||
| 20 | $data = [ |
||
| 21 | {seeder} |
||
| 22 | ]; |
||
| 23 | |||
| 24 | // Using Model |
||
| 25 | /*$model = new {name}Model(); |
||
| 26 | foreach ($data as $datum) { |
||
| 27 | try { |
||
| 28 | $model->save($datum); |
||
| 29 | } catch (ReflectionException $e) { |
||
| 30 | throw new Exception($e->getMessage()); |
||
| 31 | } |
||
| 32 | }*/ |
||
| 33 | |||
| 34 | //Using Query Builder Class |
||
| 35 | try { |
||
| 36 | $this->db->table('{table}')->insertBatch($data); |
||
| 37 | |||
| 38 | } catch (ReflectionException $e) { |
||
| 39 | throw new ReflectionException($e->getMessage()); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | } |
||
| 43 |