We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    Follow below step to create a new table in Magento 2 Database.

    1. Create a new file InstallSchema.php,  in your existing module -> Setup folder.
    2. Paste the following code in this new file.
    <?php 
    namespace VenderModulenameSetup;
     
    use MagentoFrameworkSetupInstallSchemaInterface;
    use MagentoFrameworkSetupModuleContextInterface;
    use MagentoFrameworkSetupSchemaSetupInterface;
     
    class InstallSchema implements InstallSchemaInterface
    {
     
        public function install(
            SchemaSetupInterface $setup,
            ModuleContextInterface $context
        ) {
     
            $tableobj = $setup->getConnection()->newTable($setup->getTable('contact_info'));
     
            $tableobj->addColumn(
                'entity_id',
                MagentoFrameworkDBDdlTable::TYPE_INTEGER,
                null,
                ['identity' => true,'nullable' => false,'primary' => true,'unsigned' => true,],
                'Entity ID'
            );
     
            $tableobj->addColumn(
                'first_name',
                MagentoFrameworkDBDdlTable::TYPE_TEXT,
                50,
                [],
                'first_name'
            );
    
            $tableobj->addColumn(
                'last_name',
                MagentoFrameworkDBDdlTable::TYPE_TEXT,
                50,
                [],
                'last_name'
            );
     
            $tableobj->addColumn(
                'phone',
                MagentoFrameworkDBDdlTable::TYPE_TEXT,
                15,
                [],
                'phone'
            );
     
            $tableobj->addColumn(
                'email',
                MagentoFrameworkDBDdlTable::TYPE_TEXT,
                50,
                [],
                'email'
            );
     
            $setup->getConnection()->createTable($tableobj);
        }
    }
    
    Fill the below form if you need any Magento relate help/advise/consulting.

    With Only Agency that provides a 24/7 emergency support.

      Get a Free Quote