The following are the breaking changes introduced in v0.5
. As previously mentioned, this was done to improve its maintainability and to conform more on the methods from both the Codeigniter 3
and Eloquent ORM
projects:
Before
class User extends \Rougin\Wildfire\CodeigniterModel
{
}
After
class User extends \Rougin\Wildfire\Model
{
}
When Wildfire
is used as a CI_Model
, use WildfireTrait
instead.
Before
class User extends \Rougin\Wildfire\Wildfire
{
}
After
class User extends \Rougin\Wildfire\Model
{
use \Rougin\Wildfire\Traits\WildfireTrait;
}
Before
// PaginateTrait::paginate($perPage, $config = array())
list($result, $links) = $this->user->paginate(5, $config);
After
$total = $this->db->count_all_results('users');
// PaginateTrait::paginate($perPage, $total, $config = array())
list($offset, $links) = $this->user->paginate(5, $total, $config);
The total count must be passed in the second parameter.
Before
$total = $this->user->countAll();
After
$total = $this->db->count_all_results('users');
This is being used only in PaginateTrait::paginate
.
Before
ValidateTrait::validation_errors()
After
ValidateTrait::errors()
Before
// application/models/User.php
protected $validation_rules = array();
After
// application/models/User.php
protected $rules = array();
Before
$query = $this->db->query('SELECT * FROM users');
// Wildfire::__construct($database = null, $query = null)
$wildfire = new Wildfire($this->db, $query);
After
// $this->db->query returns a CI_DB_result class
$query = $this->db->query('SELECT * FROM users');
// Wildfire::__construct($data)
$wildfire = new Wildfire($query);
If the data is a CI_DB_result
, it should be passed on the first parameter.
Before
// Wildfire::asDropdown($description = 'description')
$dropdown = $wildfire->asDropdown();
After
// Wildfire::dropdown($column)
$dropdown = $wildfire->dropdown('description');
Also take note that there is no default value in the argument.
Before
$delimiters = array('name' => 'Rougin');
// Wildfire::find($table, $delimiters = array())
$users = $wildfire->find('users', $delimiters);
After
$this->db->where('name', (string) 'Rougin');
$users = $wildfire->get('users')->result();
Use only Wildfire::find
to return single row data.
// Wildfire::find($table, $id)
$user = $wildfire->find('users', 1);
Before
use Rougin\Wildfire\Wildfire;
$wildfire = new Wildfire;
$wildfire->set_database($this->db);
$query = $this->db->query('SELECT * FROM users');
$wildfire->set_query($query);
After
use Rougin\Wildfire\Wildfire;
$wildfire = new Wildfire($this->db);
// or
$query = $this->db->query('SELECT * FROM users');
$wildfire = new Wildfire($query);
The Wildfire
parameter must be defined with either CI_DB_query_builder
($this->db
) or CB_DB_result
instances.