dtj2ww9500
2016-12-30 14:31
浏览 14

我可以使用laravel中的控制器创建数据库表吗?

How can i create database tables using controllers in laravel. Is there any way?

Actually I want to create a table using another table column values.

Eg: I have two tables called table1 and table2.

<table>
    <thead>
        <td>id</td>
        <td>name</td>
    </thead>
    <tr>
        <td>1</td>
        <td>raj</td>
    </tr>
    <tr>
        <td>2</td>
        <td>john</td>
    </tr>
    <tr>
        <td>3</td>
        <td>sam</td>
    </tr>
</table>

and I want the names as field names in table2

<table>
    <thead>
        <td>raj</td>
        <td>john</td>
        <td>sam</td>
    </thead>
</table>

And I want to create table2 using controller

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dpfad62426 2016-12-30 14:42

    Why do you want to do that!? I see no reasons!

    Anyway you can use raw query in controller :

    DB::raw(' CREATE TABLE . ..  ');
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题