Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/furkangurel/Boostr
Easy Codeigniter Query Library
https://github.com/furkangurel/Boostr
codeigniter codeigniter-library codeigniter3 codeigniternodb
Last synced: about 2 months ago
JSON representation
Easy Codeigniter Query Library
- Host: GitHub
- URL: https://github.com/furkangurel/Boostr
- Owner: furkangurel
- License: mit
- Created: 2018-04-13T07:12:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-05T07:12:06.000Z (about 6 years ago)
- Last Synced: 2024-08-04T23:30:57.870Z (5 months ago)
- Topics: codeigniter, codeigniter-library, codeigniter3, codeigniternodb
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 21
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - furkangurel/Boostr - Easy Codeigniter Query Library (PHP)
README
# 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:```php
$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`
```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
```php
User::insert($data);
```### Update
```php
User::update($id,$data);
```
You can also update multiple data.
```php
User::update($where,$data); // $where and $data must be an array
```### Delete
```php
User::delete($id);
```
You can also delete multiple data.
```php
User::delete($where); // $where must be an array
```### Select
```php
$users = User::select($where,$order_by,$limit); // $where, $order_by must be an array.
foreach($users as $user)
{
echo $user->name;
}
```### Find
```php
$user = User::find($id);
// or
$user = User::find($where);
```### Like
```php
$users = User::like($where,$order_by,$limit); // $where, $order_by must be an array.
foreach($users as $user)
{
echo $user->name;
}
```### Join
```php
$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
```php
User::count($where); // $where must be an array.
```### Max
```php
User::max('age'); //
```### Min
```php
User::min('age'); //
```### Avg
```php
User::avg('age'); //
```### Query
```php
$users = User::query("YOUR QUERY HERE"); //
```