Welcome Guest, Not a member yet? Register   Sign In
How to use Database as standalone plugin
#1

I would like to use CI active record functionality in my new project. Which files I need in order to make it fully functional (without the whole CI framework)?
Reply
#2

You're going to have to start with the database directory and either analyze the requirements or add files to fix errors as you go. Since it wasn't designed to work outside of CI, I don't know if you'll find anyone who can tell you definitively how to get it working on its own. For a start, though:
- Unless you modify the scripts, BASEPATH will need to be defined to load any of the classes
- You'll probably need to create replacements for show_error(), log_message(), load_class, and some of the other functions in /core/Common.php and CI's loader
- DB is going to look for the config file and expect APPPATH to be defined
- CI_DB_driver's display_error() method uses load_class to pull in the Lang and Exceptions classes. If you don't create replacements, you'll run into things like Lang->load() calling get_instance() to access the loader and Exceptions->show_error() looking for templates in the application errors directory.
Reply
#3

(This post was last modified: 06-29-2015, 02:47 PM by skunkbad.)

Although in alpha, and not a 100% conversion, I've been working on this:

https://bitbucket.org/skunkbad/breakout-db

It does require that you use a PSR-4 type autoloader, but some simple instructions are provided in the readme.

Please, as this project is in alpha, submit issues or bug reports through the repo.

***

Using Breakout DB is currently as easy as using this for your index.php:


PHP Code:
<?php
use Symfony\Component\ClassLoader\Psr4ClassLoader;

require 
__DIR__.'/resource/Psr4ClassLoader.php';

$loader = new Psr4ClassLoader();
$loader->addPrefix('Breakout\\'__DIR__.'/src');
$loader->register();

$db = \Breakout\DB::connect([
 
   'username' => 'root',
 
   'database' => 'test'
]); 
This assumes a MySQL database named "test" with user root and no password.
Reply
#4

I've never used, but there are some.

https://github.com/fengkaijia/codeignite...standalone
https://github.com/evolutionscript/codei...standalone
Reply




Theme © iAndrew 2016 - Forum software by © MyBB