Git Product home page Git Product logo

ci-crud's Introduction

ci-crud

Ready to go, easy to use CodeIgniter Model for basic CRUD operations on a table

Installation

Drop the files into the appropriate directory (same as what is in the repo's directory structure)

Usage

Load the model using

$this->load->model('CRUD_model', 'crud');

Given this table (which is an example)

CREATE TABLE `users` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `first_name` varchar(255) NOT NULL DEFAULT '',
    `last_name` varchar(255) NOT NULL DEFAULT '',
    `phone` varchar(25) DEFAULT NULL,
    `email` varchar(255) DEFAULT NULL,
    `created_on` datetime NOT NULL,
    `mod_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

To create your data. Pass in an array, and use your table field names as the array keys.

$data['first_name'] = 'Steve';
$data['last_name'] 	= 'Jobs';
$data['last_name'] 	= '408-555-1212';
$data['email'] 		= '[email protected]';

$this->crud->table('users')->create($data);

To update your data. In the data you pass to the method, use your table field names as the array key.

// this will update user with id 1, changing last name to 'Ives'
$id = 1;
$data['last_name'] = 'Ives';

$this->crud->table('users')->create($id, $data);

To retrive your data. Pass in the ID of the entry you want, or don't pass an id and it will return all records.

$id = 1;
$record = $this->crud->table('users')->get($id);

var_dump($record);

ci-crud's People

Watchers

 avatar  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.