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 . ..  ');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器