Git Product home page Git Product logo

php-activerecord-spark's Introduction

PHPActiveRecord Spark

PHPActiveRecord is an open source ORM library, largely based on Ruby on Rails' ActiveRecord.

This spark is used to easily integrate PHPActiveRecord into CodeIgniter 2.0+.

NOTE: PHPActiveRecord requires PHP5.3+, logging requires the PEAR Log library.

Installation

Sparks Manager

Navigate to the root of your CodeIgniter project and run

php tools/spark install php-activerecord

Manually

  • Navigate to your CodeIgniter project's 'sparks' folder
  • Extract the php-activerecord spark here, ensure it is named 'php-activerecord'

Configuration

PHPActiveRecord will use the config/database.php file to determine your database settings. It is capable of handling several connections, but will default to your $active_group connection. You may change the connection any model uses within the model itself.

PHPActiveRecord does not require you to define your database tables before use, simply extend your model from the ActiveRecord\Model class and your model will be ready for use (aside from any extra configuration you may want to add later).

Documentation

Examples, documentation, and help forums are available at http://phpactiverecord.org.

Verify PHPActiveRecord Works

Create a table in your database named tests and give it some test information, perhaps an id and a varchar column. Create at least one or two records.

Create a new file in your models directory named 'Test.php'

Give model the following content:

<?php

class Test extends ActiveRecord\Model { }

Proceed to 'welcome.php' within your controllers directory

Within the index function, enter the following prior to the view being called

$this->load->spark('php-activerecord/0.0.2');
echo '<pre>'; var_dump(Test::all()); exit;

If you've followed the steps above, you should now see a print out of your object, with the class of your Model. Success! PHPActiveRecord is now ready for use!

Logging and Profiling

If you'd like to enable logging and profiling, simply uncomment the designated block from ./libraries/PHPActiveRecord.php beginning at line 59.

HMVC Support

If you use the Module Extensions HMVC, the model folders in each module will automatically be checked for models just as the regular model folder would.

Contact and Credit

PHPActiveRecord was created and is maintained by Kien La and Jacques Fuentes. I am not associated with the developers of this project, but love the work they've done and want to make it easily accessible to the CodeIgniter community.

This spark was created and is maintained by Matthew Machuga, is hosted on GitHub, and is made possible by the GetSparks team. Please support their project!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.