how to just create tables?

29 views
Skip to first unread message

Peter Cheung

unread,
Feb 28, 2018, 1:23:37 PM2/28/18
to redbeanphp
Hi All
   how to just create tables?
Thanks

Lynesth

unread,
Apr 10, 2018, 3:07:33 PM4/10/18
to redbeanphp
If you just want to create an empty table, you have multiple solutions :

1) Use SQL directly with R::exec(). It'll let you do whatever you want.

2) R::dispense() a new bean, R::store() it and then R::trash() it.

3) You can use the writer's createTable() function :

<?php
    $R
= R::setup('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PWD);
    $R
->writer->createTable("mytable");
?>


Lyn.

Lynesth

unread,
Apr 10, 2018, 9:23:57 PM4/10/18
to redbeanphp
Actually, regarding number 3) you should be able to simply do :

<?php
    R
::getWriter()->createTable("mytable");
?>

Lyn.


Le jeudi 1 mars 2018 05:23:37 UTC+11, Peter Cheung a écrit :
Reply all
Reply to author
Forward
0 new messages