Coder Social home page Coder Social logo

boostr's Introduction

BOOSTR - Codeigniter Easy Query Library

Simple Query Library. İnsert, Update, Delete, Find, Select, Join, Count, Max, Min, Aggregate

Version2

added time_ago function and slug function.

Installation

  • Download the zip file of the latest release at https://github.com/furkangurel/Boostr/archive/master.zip

  • Extract to your application/libraries directory

  • In your config/autoload.php file, add boostr/boostr to $autoload['libraries']. So it will look like this:

    $autoload['libraries'] = array('boostr/boostr');

Usage

Defining Models

Models in Boostr represent a single table to work with. To define a model, it's about the same with CodeIgniter, but instead of extending CI_Model, the model should extends Boostr\Model class.

Example: Model for table user, located in models/user.php

class User extends Boostr\Model {
  protected $table = "user";
  protected $show = "name , surname , age";
  protected $slug= ['slug','title']; 
  protected $date="created_at";
}

The $table property is used to tell which table the model will work with.

Model properties

Here are some properties you can use to customize the model

  • $table : to define the table name. This property is mandatory to set
  • $show : to define which columns show. By default it uses all columns
  • $slug : first parameter slug column - second parameter which table will slug
  • $date : which table will be used in the date

Querying

İnsert

User::insert($data);

Update

User::update($id,$data);

You can also update multiple data.

User::update($where,$data); // $where and  $data must be an array

Delete

User::delete($id);

You can also delete multiple data.

User::delete($where); // $where  must be an array

Select

$users = User::select($where,$order_by,$limit);  // $where, $order_by  must be an array.
foreach($users as $user)
{
  echo $user->name;
}

Find

$user = User::find($id);
// or
$user = User::find($where);

Like

$users = User::like($where,$order_by,$limit);  // $where, $order_by  must be an array.
foreach($users as $user)
{
  echo $user->name;
}

Join

$join=['users','id'];   // first parameter which join table. second parameter which join column
Posts::join($join,$where,$order_by,$limit);  // join, $where, $order_by  must be an array.

Count

User::count($where);  // $where  must be an array. 

Max

User::max('age');  // 

Min

User::min('age');  // 

Avg

User::avg('age');  // 

Query

$users = User::query("YOUR QUERY HERE");  //  

boostr's People

Contributors

furkangurel avatar

Watchers

 avatar

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.