1.Download redbean.php
Lets make a project
dbconnect.php
define(‘MODE’,’PRODUCTION’);
require “rb.php”;
R::setup(‘mysql:host=localhost;dbname=mydatabase’, ‘user’,’password’);
if(MODE ==’DEVELOPMENT’){
R::debug(‘tree’);
}
else{
R::debug(false);
R::freeze( true ); // it wont made any table or adjustment by its own
}
/*
Change your database information
to know more about debugging – http://redbeanphp.com/debugging
http://redbeanphp.com/manual3_0/freeze
*/
create.php
include “dbconnect.php”;
$book = R::dispense( ‘book’ ); //table name book
$book->title = ‘Learn to Program’; //fieldname =value
$book->rating = 10;
$id = R::store( $book ); //save it will return the id of the inserted data.
list.php
include “dbconnect.php”;
$books = R::findAll( ‘book’ , ‘ ORDER BY id DESC LIMIT 10 ‘ ); //return array
foreach($books as $book){
print(“$book[id] ========== $book[title]”);
}
/*
http://redbeanphp.com/manual3_0/queries
*/