Guest User

Untitled

a guest
Jul 17th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. if (version_compare($context->getVersion(), '1.1.10', '<=')) {
  2. $installer = $setup;
  3. $installer->startSetup();
  4.  
  5. // Get tutorial_simplenews table
  6. $tableName = $installer->getTable('blog_post');
  7. // Check if the table already exists
  8. if ($installer->getConnection()->isTableExists($tableName) != true) {
  9. // Create tutorial_simplenews table
  10.  
  11.  
  12.  
  13. $table = $installer->getConnection()
  14. ->newTable($tableName)
  15. ->addColumn(
  16. 'id',
  17. Table::TYPE_INTEGER,
  18. [
  19. 'identity' => true,
  20. 'unsigned' => true,
  21. 'nullable' => false,
  22. 'primary' => true
  23. ],
  24. 'ID'
  25. )
  26. ->addColumn(
  27. 'docid',
  28. Table::TYPE_TEXT,
  29. 255,
  30. ['nullable' => false, 'default' => ''],
  31. 'docid'
  32. )
  33. ->addColumn(
  34. 'order_status',
  35. Table::TYPE_TEXT,
  36. 255,
  37. ['nullable' => false, 'default' => ''],
  38. 'Order Status'
  39. )
  40. ->addColumn(
  41. 'order_code',
  42. Table::TYPE_TEXT,
  43. 255,
  44. ['nullable' => false, 'default' => ''],
  45. 'Order Code'
  46. )
  47. ->addColumn(
  48. 'order_id',
  49. Table::TYPE_TEXT,
  50. 255,
  51. ['nullable' => false, 'default' => ''],
  52. 'Order Id'
  53. )
  54. ->addColumn(
  55. 'created_at',
  56. Table::TYPE_DATETIME,
  57. ['nullable' => false,'default' => MagentoFrameworkDBDdlTable::TIMESTAMP_INIT_UPDATE],
  58. 'Created At'
  59. )
  60. ->addColumn(
  61. 'update_at',
  62. Table::TYPE_DATETIME,
  63. ['nullable' => false, 'default' => ''],
  64. 'Updated At'
  65. )
  66. ->setComment('dfdfd')
  67. ->setOption('type', 'InnoDB')
  68. ->setOption('charset', 'utf8');
  69. $installer->getConnection()->createTable($table);
  70. }
  71. $installer->endSetup();
  72.  
  73.  
  74. }
  75.  
  76.  
  77. Warning: array_key_exists() expects parameter 2 to be array, string given i
  78. n /var/www/html/readyresale_beta/vendor/magento/framework/DB/Ddl/Table.php
  79. on line 352
  80.  
  81. $installer = $setup;
  82. $installer->startSetup();
  83. if (version_compare($context->getVersion(), '1.1.10') < 0) {
  84. // Get module table
  85. $tableName = $installer->getTable('blog_post');
  86.  
  87. // Check if the table already exists
  88. if ($installer->getConnection()->isTableExists($tableName) == true) {
  89. // Declare data
  90. $columns = array(
  91. 'id' => array(
  92. 'type' => Table::TYPE_INTEGER,
  93. 'size' => null,
  94. 'options' => array('nullable' => false, 'default' => ''),
  95. 'comment' => 'Id',
  96. ),
  97. 'docid' => array(
  98. 'type' => Table::TYPE_INTEGER,
  99. 'size' => null,
  100. 'options' => array('nullable' => true, 'default' => ''),
  101. 'comment' => 'Docid',
  102. ),
  103. // Do the same for the other...
  104. );
  105.  
  106. $connection = $installer->getConnection();
  107. foreach ($columns as $name => $definition) {
  108. $connection->addColumn($tableName, $name, $definition);
  109. }
  110. }
  111. }
Add Comment
Please, Sign In to add comment