Questions tagged [redbean]

RedBeanPHP is an open-source ORM library written for PHP.

About

RedBeanPHP is open-source object-relational mapping software written in PHP.

The main proponent of this software is the configuration-less way that the software will create the tables and columns on-the-fly as you run your PHP code. It does this by working in a 'fluid' mode where the software will check for requested columns when the code is running and create them if they do not exist, it will even broaden the type of a column, for example if your application changes from storing numbers to text.

Once you are happy with your structure and do not want the data structure to change any further you can invoke the freeze command:

R::freeze( true ); //will freeze redbeanphp

This will lock your schema and prevent changes.

Setup & Using Redbean

RedBeanPHP is packaged up into a single php file (rb.php approx 285KB) so that a single include statement and you're ready to go:

require 'rb.php';

Working with Data

An example of CRUD operations with RedBean:

$post = R::dispense('post');
$post->text = 'Hello World';

$id = R::store($post);       //Create or Update
$post = R::load('post',$id); //Retrieve
R::trash($post);             //Delete

Database Compatibility

RedBean works with many database engines in fluid and frozen mode:

MySQL 5 and higher

SQLite 3.6.19 and higher

PostgreSQL 8 and higher

CUBRID (since 3.2)

Oracle* (since 3.3, read note)

278 questions
0
votes
1 answer

Link in three tables in php redbeans

I have three tables USER user_id,name EVENT event_id, name,desc PARTICIPATION id, type 1 yes 2 no 3 maybe I want to handle relationship among these in table user_event_participation id , user_id,event_id,participation_id 1 …
alwaysLearn
  • 6,882
  • 7
  • 39
  • 67
0
votes
1 answer

RedBeanPHP, NotORM and DibiPHP. Which one of these simple ORM is the best?

I am looking for a simple ORM for PHP for a small project. I found 3 of them. Do you have any idea of which one is the best? http://redbeanphp.com http://www.notorm.com http://dibiphp.com I appreciate any help. Thanks.
Lawrence
  • 309
  • 7
  • 18
0
votes
2 answers

How to exclude tables/children from result in RedBeanPHP

I have modelled a relation like this is RedBeanPHP: Car id color ownPart Part id name So RedBean creates the SQL tables as expected: Car id color Part id name car_id This works great. However, I have other tables in my DB, e.g.…
A2i_
  • 398
  • 3
  • 13
0
votes
1 answer

RedBean crash if field begin with number

I have a table called User with a field called 10kssc of type integer If I do this on an existing bean echo $user->10kssc; The code died with just an empty tab I can see this is in the docs for version 3 which doesnt suggest a field name cant…
user2274191
  • 843
  • 2
  • 14
  • 24
0
votes
2 answers

Redbean + Slim Framework issue , RedBeanPHP\RedException\SQL SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test_api.post' doesn't exist

I just want to create an application using Slim Framework and RedBeanPHP4, i'm using mysql and the name of database is 'test_api',the db has been created with empty table as my knowledge when using redbeanphp, we could create table on-the-fly. and…
mirzalazuardi
  • 45
  • 1
  • 8
0
votes
2 answers

How to perform Inner joins , left joins with readbean ORM?

If I have 2 tables one is users and one is stores , the users id field is associated with the store's user_id field . Now if I want to find all those users who has a store how can I perform it on readbean ? and please do explain as I'm just getting…
Biraj Ghosh
  • 1
  • 1
  • 2
0
votes
1 answer

Is it possible to set 2 separate unique fields using Redbean ORM

I am using the redbeanPHP ORM and mysql. I have the following table: CREATE TABLE `mast` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `note` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `geolocation` varchar(255) COLLATE utf8_unicode_ci…
user1592380
  • 34,265
  • 92
  • 284
  • 515
0
votes
1 answer

Redbean's Exception Handling not working?

I'm new to RedbeanPHP (v4.0.4), and trying it out a bit. However, whenever I try to force a mistake (load unexisting bean, store a wrong type value, etc.), it won't throw any exceptions. It always seems to be successful, whatever mistake I…
jlmmns
  • 837
  • 4
  • 14
  • 25
0
votes
2 answers

redbeanPHP database connect doesn´t work in phpUnit bootstrap

i am using redbeanPHP since two years. On my new project i wan´t to implement unit-tests from the beginning. I installed phpUnit and without the database connection all works fine. I now wan´t to test my classes with database intigration. I know…
schw4ndi
  • 231
  • 4
  • 18
0
votes
1 answer

Can't access some of the object properties PHP (RedBeanPhp object)

I have var_dump of my object. Here is the output. In my code object is $d->depositType. When I echo $d->depositType->id or $d->depositType->years I get the values I want. But when I try to get to $d->depositType->name or $d->depositType->name I get…
Andriy Haydash
  • 357
  • 1
  • 14
  • 35
0
votes
2 answers

Redbeanphp one to one relation

In my project have 2 entites in my db namely User and Account. One User has one account.User table has account_id field as foreign key to reference Account entity. I am generating automaticly a new account for user. Everything gets created as I…
Andriy Haydash
  • 357
  • 1
  • 14
  • 35
0
votes
1 answer

RedbeanPHP: Fatal error: function isFrozen() on a non-object in rb.php

I have a query SELECT post.* FROM wp_posts as post , wp_term_relationships as term_relation, wp_term_taxonomy as term_texomony, wp_icl_translations as trans WHERE post.post_status='publish' AND post.post_type='post' AND…
HMagdy
  • 3,029
  • 33
  • 54
0
votes
0 answers

Creation of a "temporary" table for daily operations?

I have a mysql table MAINLIST. CREATE TABLE `MAINLIST` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `NAME` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `email` tinyint(1) unsigned DEFAULT NULL, `contact` tinyint(1) unsigned DEFAULT…
user1592380
  • 34,265
  • 92
  • 284
  • 515
0
votes
1 answer

Intersection with redbeanphp

I have an array $mycontacts of beans of type $contact where: $contact->id = $x $contact->name = $y $contact->email= $z I want to check the $mycontacts array against a second array $contacted also of type $contact. I want to perform $mycontacts -…
user1592380
  • 34,265
  • 92
  • 284
  • 515
0
votes
1 answer

Accessing items of a bean object

i'm using redbeanphp like this $r = R::find('chat', 'room_id = ? AND time > ? ORDER BY time ASC', array($w->id, $_POST['latest_timestamp'])); Now i a have a list of bean objects inside $r so is there any way to access rows without convert it to…
ms000
  • 1
  • 1