DuplicateModel.php 859 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * @author gaobinzhan <gaobinzhan@gmail.com>
  4. */
  5. namespace EasySwoole\ORM\Tests\models;
  6. use EasySwoole\DDL\Blueprint\Table;
  7. use EasySwoole\Mysqli\QueryBuilder;
  8. use EasySwoole\ORM\AbstractModel;
  9. use EasySwoole\ORM\DbManager;
  10. class DuplicateModel extends AbstractModel
  11. {
  12. protected $tableName = 'duplicate';
  13. protected $autoTimeStamp = false;
  14. public function __construct(array $data = [])
  15. {
  16. $table = new Table($this->tableName);
  17. $table->setIfNotExists();
  18. $table->int('id');
  19. $table->int('id1');
  20. $table->char('nickname', 30);
  21. $table->char('nickname1', 30);
  22. $table->primary('id', ['id', 'id1']);
  23. $builder = new QueryBuilder();
  24. $builder->raw($table->__toString());
  25. DbManager::getInstance()->query($builder);
  26. parent::__construct($data);
  27. }
  28. }