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

RedBeanPHP: find all books where property is null?

I tried this, but I dont get any results: $Books= R::findAll( 'books' , ' WHERE accepted IS NULL ORDER BY update_time DESC LIMIT 100 ' ); What should I do? EDIT: My PHP: $requests = array(); $Books = R::findAll( 'books' , '…
Suisse
  • 3,467
  • 5
  • 36
  • 59
0
votes
3 answers

Update in RedBean

I am creating a Data Entry system. Now I am able to add data from a form. But update does not work.Instead when I try to update it adds another entry. This is my add.php.
0
votes
1 answer

Redbean php multiple many-to-many relations to same table

Here is my situation: user have list of liked objects and list of disliked. I want to act like this: list($cat, $dog) = R::dispense('object', 2); $user->sharedLikedobjectsList[] = $cat; $user->sharedDislikedobjectsList[] = $dog; But afterall…
ichi
  • 23
  • 5
0
votes
1 answer

how to create column alias in select from database by redbeanphp?

i want to know how create a query such as this in redbeanphp: select concat(first_name,' ',last_name) AS fullname from person; i know redbean has a bindFunc Method but i do not know how to do this and this topic was not cover in redbean…
Navid_pdp11
  • 3,487
  • 3
  • 37
  • 65
0
votes
1 answer

how to use bindFunc method in redbeanphp?

i am working on a project that need to work with spatial object in mysql and i choose redbeanphp as ORM system in this project. i found redbeanphp so terrific and awesome. i search in google and found this link that say bindFunc method can help me…
Navid_pdp11
  • 3,487
  • 3
  • 37
  • 65
0
votes
2 answers

how to create a foreign key with custom name in redbeanphp

I have two tables user and comment: a user can post a comment to another user. I want create two foreign key from comment table to user table witch one contain comment writer user_id and another contain comment owner user_id. i use this code…
Navid_pdp11
  • 3,487
  • 3
  • 37
  • 65
0
votes
0 answers

Making E-mail as primary key in readbeans php

How can I make email field as unique and primary key in redbeans php ? Is there any way to do that?
0
votes
1 answer

query over many to many relationship in redbeanphp

i have two tables which are "user" and "estate" and i make a many-many relation between those table with this code : $user->link("estatetrans", (array("trtype" => $trtype, "indate" => time())))->estate = $estate; "estatetrans" is name of table…
Navid_pdp11
  • 3,487
  • 3
  • 37
  • 65
0
votes
1 answer

How to display all records from a table with RedBeanPHP?

What is the RedBeansPHP equivelant for this code? $sql = "SELECT * FROM user"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo $row["name"]."
"; …
Ducky
  • 409
  • 1
  • 7
  • 24
0
votes
2 answers

Can I do multi mapping with redbeanphp?

can I load an object and it's relations with just a query? so, if I have select * from parent inner join child on parent.id = child.parent_id could I get and array of parent beans with is ownChild informed just from that query? something like…
Jokin
  • 4,188
  • 2
  • 31
  • 30
0
votes
1 answer

object vs array, { } vs [ ], echo vs print_r

I need a clarification regarding the difference between data objects and arrays in PHP+mySQL and something I think is related: representing "array-type data" with { } vs [ ] I am using PHP, mySQL and RedBean ORM. I pulled out a record (table row)…
thanks_in_advance
  • 2,603
  • 6
  • 28
  • 44
0
votes
1 answer

How can I dynamically build a parameterized query for RedBeanPHP 4?

So I have some data coming in via POST from a form with a large number of checkboxes and I'm trying to find records in the database that match the options checked. There are four sets of checkboxes, each being sent as an array. Each set of…
dev_willis
  • 530
  • 4
  • 6
  • 18
0
votes
1 answer

RedBeanPHP fetchAll only returning one row

I am making a call to the database to fetch some data. I have tried the request in SQL, and it works fine. I have coded the query using PDO, and it works fine. But using RedBeanPHP with the same query only returns one…
James Jeffery
  • 12,093
  • 19
  • 74
  • 108
0
votes
1 answer

Using RedBeanPHP, findOne() does not find anything

I have the following code: $tuba = R::findOne("tuba", "photoNum = ?", [$_POST["photoNum"]]); if(empty($tuba)) exit("

No entry with photo number ".$_POST["photoNum"]." found.

"); When I pass it a value for photoNum that I…
dev_willis
  • 530
  • 4
  • 6
  • 18
0
votes
1 answer

Does r::find in redbean support more than one search field

I am trying to search by more than one criteria. I have searched Redbean's site for the correct syntax but all they offer is examples using only one search criteria. $match = R::find('tuba', ' displayType = ? ', [ '$displayType' ]); I am trying to…