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
0 answers

Zurmo reports (Export to CSV) painfully slow

So I have a XAMPP setup with Zurmo 2.6.5 running on it. Everything works like a charm. The speed at which it pulls up contacts, goes through pages, etc is considerably fast. I have 2 GB RAM and this is the only web app that runs on it. You can call…
MzQ
  • 5
  • 2
0
votes
1 answer

How to get result of complex query in redbeanphp

So I have this query $sql = "set @row_number := 0; SELECT * FROM ( SELECT user_id, @row_number := @row_number +1 pos FROM user ORDER BY plays DESC …
shark255
  • 45
  • 1
  • 7
0
votes
1 answer

RedBean relation definitions

I'm not following, how exactly I define relations in RedBean, not on the fly. I have a user which can have a parent user that is considered an employer. On the opposite side, a user can have employees which are also users. How would I go about…
casraf
  • 21,085
  • 9
  • 56
  • 91
0
votes
1 answer

how to redirect to secure section of website with Login script created in redbeanphp

$email = trim($_POST['email']); $pass = md5(trim($_POST['password'])); $user = R::findOne("user"," email = ? AND password = ? ", array($email,$pass)); if($user != NULL) { // good login …
Harshit Laddha
  • 2,044
  • 8
  • 34
  • 64
0
votes
0 answers

RedbeanPHP - How to Create a bean with specific data type without initializing the variable or bean created

I want to be about to create a redbeanPHP bean without initializing the bean, here is an example: //create bean sample data as a table in a database $sampledata = R::dispense('sampledata'); //Create column $sampledata->slotName = "John Doe";…
Anthony
  • 41
  • 1
  • 5
0
votes
0 answers

PHP Redbean not processing tokens properly?

Ok, look at this code: // Query building! $query_params = array(); $query = ' '; if (!empty($data['estado'])) { $query .= 'estado = ? AND '; $query_params[] = $data['estado']; } if (!empty($data['ref'])) { …
Leonardo Arroyo
  • 573
  • 6
  • 16
0
votes
2 answers

RedBeanPHP loading beans 'id' not found

Good Day, I am trying to load some data from RedBean from my PHP table: R::freeze( true ); $idfunctions=1; $function = R::load('functions', $idfunctions); if (!$function->id) { echo "...help bean not found!!.."; } The table functions has a primary…
raaj
  • 2,869
  • 4
  • 38
  • 58
0
votes
1 answer

RedBean simple model random id's

I inherited a web project that has been developed using Zend Framwork and Redbean Simple Model, and I am not too familiar with these. Pages seem to be generated dynamically to edit entities. The problem I am facing is that html elements in the…
Jean-François Beauchamp
  • 5,485
  • 8
  • 43
  • 77
0
votes
1 answer

redBeanPHP - Unique Value

I'm trying to set a variable for a user input text field that needs to check the database that it's unique. I have used Codeigniter before and in the you set validation for this like: $this->form_validation->set_rules('name','Name required…
the_unforgiven_II
  • 361
  • 3
  • 10
  • 28
0
votes
1 answer

How to access the link bean dependent on both tables/table entries?

There are two tables with a many-to-many relation, for example: base base_resource resource id | name base_id | resource_id | amount id | name ----+------ ---------+-------------+------- …
charlieMACK
  • 165
  • 9
0
votes
1 answer

redbean 3.4 Undefined index: id

I want problem with any tables when id. #MYTABLE publireportaje idxx - name - last #THE CODE R::setup('mysql:host=localhost;dbname=demo','root','xxxxx'); R::freeze(true); $data = R::find('publireportaje'); echo '
';
print_r($data); 

#THE…
Alexd2
  • 1,044
  • 2
  • 15
  • 28
0
votes
2 answers

Is it bad practice to have a view talk directly to the model layer?

I recently discovered the excellent redbean ORM library for PHP, which makes performing CRUD operations trivial in my web application, but I recently implemented some additional functionality that I'm starting to question. To make saving data even…
jerry
  • 2,743
  • 9
  • 41
  • 61
0
votes
1 answer

retrieving multiple columns from table using redbeanphp

I have a query which retrieves 3 columns from table which works fine in phpmyadmin SELECT cab_id, SUM(IF(rating=1,1,0)) as up, SUM(IF(rating=0,1,0)) as down FROM rating WHERE cab_id=101 table->'rating' Can anyone help me to find how I can get this…
Jojo George
  • 159
  • 16
0
votes
1 answer

RedBeanPHP multiple FK to the same table

I'm using the latest version of RedBeanPHP. I'm modeling a football fixture structure. A single game, is performing by 2 teams and belong to a single game day (fixture in database). $o = R::dispense('game'); $o->l = R::load('team',$l[$i]); $o->v =…
mauriblint
  • 1,802
  • 2
  • 29
  • 46
0
votes
1 answer

handling duplicates with a persistent UNIQUE constraint on a composite of two columns in a table?

I have a number of records that I would like to insert into a MYSQL table. I am using PHP. Some of them are duplicates. I am using the redbeanPHP orm (http://redbeanphp.com/) My strategy is to use a composite UNIQUE constraint made of 2 columns(…
user1592380
  • 34,265
  • 92
  • 284
  • 515