Posted By

FabulousGee on 12/14/17


Tagged


Versions (?)

ATK4-Data


 / Published in: PHP
 

Showing a possible bug to devs

  1. <?php
  2.  
  3. /*
  4. CREATE TABLE `i_dienstplan` (
  5.   `UID` int(255) NOT NULL,
  6.   `Date` date NOT NULL,
  7.   `Version` int(255) NOT NULL,
  8.   `TEST` json DEFAULT NULL
  9. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  10. */
  11.  
  12. use \atk4\data\Model;
  13.  
  14. abstract class AbstractModel extends Model {
  15. function init()
  16. {
  17. parent::init();
  18. }
  19.  
  20. }
  21.  
  22. class DienstplanModel extends AbstractModel {
  23. public $table = 'i_dienstplan';
  24. public $id_field = 'UID';
  25.  
  26. function init()
  27. {
  28. parent::init();
  29.  
  30. $this->addField('Date', ['title'=>'Datum', 'type' => 'date']);
  31. $this->addField('Version');
  32. $this->addField('TEST', ['title'=>'Test desc', 'serialize'=>'json','standard'=>NULL]);
  33. }
  34. }
  35.  
  36. $db = new \atk4\data\Persistence_SQL('mysql:host=localhost;port=3306;dbname=db1,root,root');
  37. $todayDateTime = new \DateTime('now', new \DateTimeZone('UTC'));
  38. $todayDateTime->setTime(0,0);
  39.  
  40. $dienstplanModel = new DienstplanModel($db);
  41. $dienstplanModel->set('Date', $todayDateTime);
  42. $dienstplanModel->set('Version', 1);
  43. $dienstplanModel->set('TEST', array('a', 'b', 'c'));
  44. $dienstplanModel->saveAndUnload();
  45.  
  46. ?>

Report this snippet  

You need to login to post a comment.