Please help change field name ID

64 views
Skip to first unread message

norber...@gmail.com

unread,
Apr 19, 2018, 9:22:39 AM4/19/18
to redbeanphp
Hello! I need help. Could you please tell me how I can change field name  ID for those that I need (i need id_firms)? I know that there is an unchangeable name of primary key field , but I would like to change it for my own. I know that there is a command formatBeanID(), but I have no idea where I should enter this command.
May be in that piece of the code where I save data:

R::ext('xdispense', function($all_pracownik){
                        return R::getRedBean()->dispense($all_pracownik);
                    });
            $all_pracownik= R::xdispense('all_pracownik');
                    .............................

                    $all_pracownik->number_phone=$data['number_phone'];
                    R::store($all_pracownik);


Lynesth

unread,
Apr 19, 2018, 9:25:34 PM4/19/18
to redbeanphp
Hello,

I didn't really understand what you need to do.
Could you explain to us what the all_pracownik table looks like ?

Just a note:
Beans shouldn't have underscore in their types, as this is reserved by RedBean for tables that link beans together.
Anyway since it seems you need it (using xdispense to bypass the check wasn't such a bad idea), you should use the new DispenseHelper::setEnforceNamingPolicy( false ) instead (RedBean 5.1).

Regards,

Lyn.

norber...@gmail.com

unread,
Apr 20, 2018, 6:41:56 AM4/20/18
to redbeanphp
Thank you for your reply! I just need to format  the name of the primary key column (ID) to my liking (ID_FIRMS) by using the formatBeanID() or others methods, but I don't know how to format it. I've found a decision for my question, but I can't open an example.

Here is the link with example: https://stackoverflow.com/questions/9554787/does-redbean-need-a-id-primary-key?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

Lynesth

unread,
Apr 20, 2018, 9:10:11 AM4/20/18
to redbeanphp
Oh I see.

Unfortunatly, the bean formatter has bean removed quite some time ago so you cannot customize database schema anymore.
You can't modify this directly in your db ?

norber...@gmail.com

unread,
Apr 20, 2018, 11:02:20 AM4/20/18
to redbeanphp
I can, but RBphp can't work with colums who have a different name than "id".  I changed  name column  in db and right away RBphp write error. Sorry for my english, i'm from Poland

Cristian Gomez

unread,
Aug 15, 2018, 9:14:33 AM8/15/18
to redbeanphp


On Friday, April 20, 2018 at 11:02:20 AM UTC-4, norber...@gmail.com wrote:
I can, but RBphp can't work with colums who have a different name than "id".  I changed  name column  in db and right away RBphp write error. Sorry for my english, i'm from Poland

I have the same situation, the message that it shows me is:
[Sat Aug 11 14:21:24 2018] PHP Notice:  Undefined index: id in C:\Users\HP\Development\freelance\courier\courier-api\vendor\gabordemooij\redbean\RedBeanPHP\Repository.php on line 569

Reply all
Reply to author
Forward
0 new messages