- Download RedbeanPHP and drop the two files (._rb.php and rb.php) in system/application/libraries
- Create a library class called Redbean.php with the contents shown below, and drop it in the same directory
- Use it in your controller
Redbean.php
ci =& get_instance(); // Include database configuration include(APPPATH.'/config/database.php'); // Include required files include(APPPATH.'/libraries/rb.php'); // Database data $hostname = $db[$active_group]['hostname']; $username = $db[$active_group]['username']; $password = $db[$active_group]['password']; $database = $db[$active_group]['database']; // Create RedBean instance $toolbox = RedBean_Setup::kickstartDev('mysql:host='.$hostname.';dbname='.$database, $username, $password); $this->ci->rb = $toolbox->getRedBean(); } }
Using it somewhere in your controller
// example code of creating a 'post' table $post = $this->rb->dispense("post"); $post->title = 'My first post from CodeIgniter'; $post->body ='Lorem ipsum dolor sit amet, consectetur adipisicing elit....'; $post->created = time(); $id = $this->rb->store($post);
After running this controller, you should see a 'post' table created. Done!
What you should see in phpMyAdmin |
6 comments:
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.
python Training institute in Pune
python Training institute in Chennai
python Training institute in Bangalore
Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
Data Science Training in Indira nagar
Data Science Training in btm layout
Python Training in Kalyan nagar
Data Science training in Indira nagar
Data Science Training in Marathahalli
Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
rpa training in bangalore
best rpa training in bangalore
rpa training in pune | rpa course in bangalore
rpa training in chennai
Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
Best Devops Training in pune
Devops Training in Bangalore
Microsoft azure training in Bangalore
Power bi training in Chennai
Attend The Python training in bangalore From ExcelR. Practical Python training in bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Python training in bangalore.
python training in bangalore
This post is so interactive and informative.keep update more information...
aws training in bangalore
devops training in bangalore
devops course in bangalore
Post a Comment