Welcome Guest, Not a member yet? Register   Sign In
CRUD_Model with Single Line Pagination and Lots More
#1

[eluser]Developer13[/eluser]
Check it out, read the README and use it for your projects.

https://github.com/jesseterry/CodeIgniter-CRUD-Model

I hope you find it useful!
#2

[eluser]Developer13[/eluser]
Has anybody tried this out? Any thoughts or criticisms? Keep in mind, it's not meant to be an ORM, if that's what you're into. It's just a handy dandy base model.
#3

[eluser]ZaLiTHkA[/eluser]
[quote author="Developer13" date="1342217494"]Has anybody tried this out? Any thoughts or criticisms? Keep in mind, it's not meant to be an ORM, if that's what you're into. It's just a handy dandy base model.[/quote]
I just found your thread this morning.. I'm working on an intranet frontend for one of our SQL databases at work. Considering I'm only working with one database (or at most, one database type), full scale ORM is definitely a bit over the top for this project, looks like your CRUD_Model will fit my projects needs like a glove.

I'm still very much in the planning stage at the moment, but I'll let you know how it goes when I get to the point of actually pushing/pulling data. Smile
#4

[eluser]ZaLiTHkA[/eluser]
Hey D13, I'm getting an error when I try use this model..

Quote:Fatal error: Class 'CRUD_Model' not found in C:\EasyPHP\www\AESPortal_CI\application\models\company_model.php on line 3

In my company_model.php file, line 3 is the start of my class:
Code:
<?php

class Company_Model extends CRUD_Model {
function __construct() {
  parent::__construct();
}

public $table = "Company";
public $primary_key = "Company.CompanyID";

public function default_select() {
  $this->db->select('Company.*');
}

public function default_order_by() {
  $this->db->order_by('Company.CompanyID');
}
}

Then in my controller I load the model at the start of my Test class:
Code:
<?php

class Test extends CI_Controller {
function index() {
  // Get Company Data
  $this->load->model('company_model');
  $company_records = $this->company->get()->result();

I did first have CRUD_Model.php in my /application/models folder, but even after moving it to the /application/core folder (as stated in the readme on Github) it still throws the same error.

I am still rather new to the world of PHP, so this may very well just be something I'm doing wrong.. Any ideas?

----------------------------------------

Update: Ok, I've managed to get it working, but I'm not sure if this is the correct way to do this...

CRUD_Model.php is in /application/models (not /application/core), and I added this to the top of my controller's index() function:
Code:
$this->load->model('crud_model');

As I say, this works.. But only if CRUD_Model.php is in my /models folder. So, am I perhaps still doing something wrong here?
#5

[eluser]Developer13[/eluser]
Sorry but I'm not sure why it wouldn't work if you have it in application/core. That's where it should be. Using $this->load->model('crud_model') is definitely not the solution.
#6

[eluser]ZaLiTHkA[/eluser]
[quote author="Developer13" date="1345129111"]Sorry but I'm not sure why it wouldn't work if you have it in application/core. That's where it should be. Using $this->load->model('crud_model') is definitely not the solution.[/quote]
I thought as much, unfortunately I couldn't get it working, so I've actually removed it from this project for the moment. If I have time, I'll try a fresh CI project with only your CRUD_model this weekend and see what comes of it. Smile
#7

[eluser]Developer13[/eluser]
You know - I use wiredesignz's Modular Extensions with *all* of my CodeIgniter projects, so I didn't even think about this. I believe if you're not using Modular Extensions, then you'd want to rename the model to MY_Model (and rename the class as well) when you drop it into your core folder.

Sorry about that! Hope this helps.
#8

[eluser]Developer13[/eluser]
All - I've updated the code and readme @ Github to correct my stupidity with the CRUD_Model vs. MY_Model. Personally I think this model kicks some major monkey ass, so take a look and let me know what you think. I'll probably be putting together a screencast sometime soon for those who like the visuals.

https://github.com/jesseterry/CodeIgniter-CRUD-Model




Theme © iAndrew 2016 - Forum software by © MyBB