Download the PHP package onlyphp/codeigniter3-model without Composer

On this page you can find all versions of the php package onlyphp/codeigniter3-model. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package codeigniter3-model

Advanced MY_Model for CodeIgniter 3 πŸš€

A powerful extension of CodeIgniter 3's base Model class that brings modern ORM features to your CI3 applications. This package introduces Laravel-style eloquent features, advanced query capabilities, and robust database interaction layers while maintaining CodeIgniter's simplicity.

⚠️ Warning

DO NOT USE THIS PACKAGE IN PRODUCTION

This package is under active development and may contain critical bugs. It is primarily intended for personal use and testing. The current version has not undergone rigorous testing and may be unstable.

πŸ“ Requirements

Add this line in composer.json before install or update.

πŸ”§ Installation

✨ Key Features

πŸ“š Basic Model Configuration

Here's a complete example of how to set up your model with all available configurations:

πŸ“š Usage Examples

Basic Query Operations

Soft Deletes

πŸ”„ Relationships and Eager Loading

Defining Relationships

πŸ“„ Pagination Examples

Basic Pagination

Ajax DataTables Integration

πŸ”’ Security Features

XSS Protection

Validation

πŸ” Advanced Query Examples

πŸ“„ License

This project is licensed under the MIT License.

🏷️ Changelog

Click to view changelog ### v1.0.0 (2025-01-01) - Initial release - Basic query builder functionality - Soft delete implementation - Basic relationship handling - Security layer implementation

πŸ“« Support

For bugs and feature requests, please use the GitHub Issues page.

πŸ™ Acknowledgments

πŸ“„ Basic Documentation

Query Functions

Function Description
rawQuery() Execute raw SQL queries directly. Useful for complex queries not supported by active record.
table() Specifies the database table for the query.
select() Defines the columns to retrieve in a query. Similar to CodeIgniter’s select().
where() Adds a basic WHERE clause to the query. Similar to Laravel's where().
orWhere() Adds an OR WHERE clause. Similar to Laravel's orWhere().
whereNull() Adds a WHERE clause to check for NULL values. Similar to Laravel's whereNull().
orWhereNull() Adds an OR WHERE clause to check for NULL values. Similar to Laravel's orWhereNull().
whereNotNull() Adds a WHERE clause to check for non-NULL values. Similar to Laravel's whereNotNull().
orWhereNotNull() Adds an OR WHERE clause to check for non-NULL values. Similar to Laravel's orWhereNotNull().
whereExists() Adds a WHERE EXISTS clause. Similar to Laravel's whereExists().
orWhereExists() Adds an OR WHERE EXISTS clause. Similar to Laravel's orWhereExists().
whereNotExists() Adds a WHERE NOT EXISTS clause. Similar to Laravel's whereNotExists().
orWhereNotExists() Adds an OR WHERE NOT EXISTS clause. Similar to Laravel's orWhereNotExists().
whereNot() Adds a WHERE NOT clause for negating conditions. Similar to Laravel's whereNot().
orWhereNot() Adds an OR WHERE NOT clause for negating conditions. Similar to Laravel's orWhereNot().
whereTime() Adds a WHERE clause for a time comparison. Similar to Laravel's whereTime().
orWhereTime() Adds an OR WHERE clause for a time comparison. Similar to Laravel's orWhereTime().
whereDate() Adds a WHERE clause for a date comparison. Similar to Laravel's whereDate().
orWhereDate() Adds an OR WHERE clause for a date comparison. Similar to Laravel's orWhereDate().
whereDay() Adds a WHERE clause for a specific day. Similar to Laravel's whereDay().
orWhereDay() Adds an OR WHERE clause for a specific day. Similar to Laravel's orWhereDay().
whereYear() Adds a WHERE clause for a specific year. Similar to Laravel's whereYear().
orWhereYear() Adds an OR WHERE clause for a specific year. Similar to Laravel's orWhereYear().
whereMonth() Adds a WHERE clause for a specific month. Similar to Laravel's whereMonth().
orWhereMonth() Adds an OR WHERE clause for a specific month. Similar to Laravel's orWhereMonth().
whereIn() Adds a WHERE IN clause. Similar to Laravel's whereIn().
orWhereIn() Adds an OR WHERE IN clause. Similar to Laravel's orWhereIn().
whereNotIn() Adds a WHERE NOT IN clause. Similar to Laravel's whereNotIn().
orWhereNotIn() Adds an OR WHERE NOT IN clause. Similar to Laravel's orWhereNotIn().
whereBetween() Adds a WHERE BETWEEN clause. Similar to Laravel's whereBetween().
orWhereBetween() Adds an OR WHERE BETWEEN clause. Similar to Laravel's orWhereBetween().
whereNotBetween() Adds a WHERE NOT BETWEEN clause. Similar to Laravel's whereNotBetween().
orWhereNotBetween() Adds an OR WHERE NOT BETWEEN clause. Similar to Laravel's orWhereNotBetween().
join() Adds an INNER JOIN to the query. Similar to CodeIgniter’s join().
rightJoin() Adds a RIGHT JOIN to the query. Similar to Laravel's rightJoin().
leftJoin() Adds a LEFT JOIN to the query. Similar to Laravel's leftJoin().
innerJoin() Adds an INNER JOIN to the query. Same as join().
outerJoin() Adds an OUTER JOIN to the query. Similar to Laravel's outerJoin().
limit() Limits the number of records returned. Similar to CodeIgniter's limit().
offset() Skips a number of records before starting to return records. Similar to CodeIgniter's offset().
orderBy() Adds an ORDER BY clause. Similar to Laravel's orderBy().
groupBy() Adds a GROUP BY clause. Similar to Laravel's groupBy().
groupByRaw() Adds a raw GROUP BY clause. Similar to Laravel's groupByRaw().
having() Adds a HAVING clause. Similar to Laravel's having().
havingRaw() Adds a raw HAVING clause. Similar to Laravel's havingRaw().
chunk() Process data in chunks to handle large datasets efficiently. Similar to Laravel's chunk().
get() Retrieves all data from the database based on the specified criteria.
fetch() Retrieves a single record from the database based on the specified criteria.
first() Retrieves the first record based on the query.
last() Retrieves the last record based on the query.
count() Counts the number of records matching the specified criteria.
find() Finds a record by its primary key (ID).
withTrashed() Retrieves both soft deleted and non-deleted records from the database. When using this method, the results include records that have been soft deleted (i.e., those with a deleted_at timestamp) alongside active records.
onlyTrashed() Retrieves only the records that have been soft deleted (i.e., records with a deleted_at timestamp). This method excludes active (non-deleted) records from the query results.
toSql() Returns the SQL query string (without eager loading query).

Pagination Functions

Function Description
setPaginateFilterColumn() Sets the filter conditions for pagination. If not set, all columns from the main table are queried.
paginate() Custom pagination method that works without the datatable library. Allows paginating results based on the specified criteria.
paginate_ajax() Pagination method specifically designed to work with AJAX requests and integrate with datatables.

Relationship Functions (in model only)

Function Description
hasMany() Defines a one-to-many relationship. Similar to Laravel's hasMany().
hasOne() Defines a one-to-one relationship. Similar to Laravel's hasOne().

Eager Load Functions

Function Description
with() Eager loads related models to avoid the N+1 query issue. Similar to Laravel's with().

CRUD Functions

Function Description
create() Inserts a single new record in the database based on the provided data (will return the last inserted id).
batchCreate() Inserts a multiple new record in the database based on the provided data in one operation.
patch() Updates a specific record by its primary key (ID) set at $primaryKey property in model.
patchAll() Updates multiple existing records based on specified conditions in one operation.
batchPatch() Updates a multiple existing record by using specific column/primarykey (does not required any where condition).
destroy() Deletes a specific record by its primary key (ID) set at the $primaryKey property in the model. If soft delete is enabled ($softDelete = true), the record is not permanently removed but flagged as deleted by setting a deleted_at or $_deleted_at_field property to timestamp.
destroyAll() Deletes multiple records based on specified conditions. If soft delete is enabled ($softDelete = true), the record is not permanently removed but flagged as deleted by setting a deleted_at or $_deleted_at_field property to timestamp.
forceDestroy() Permanently deletes a specific record by its primary key (ID) set at the $primaryKey property in the model, bypassing the soft delete mechanism if it is enabled. This method removes the record entirely from the database.
insertOrUpdate() Determines whether to insert or update a record based on given conditions. Similar to Laravel's updateOrInsert().
restore() Restores a soft-deleted record by removing the deleted_at timestamp, making the record active again. This method only applies to records that have been soft deleted (i.e., those with a non-null deleted_at timestamp). If soft deletes are enabled ($softDelete = true), the restore() function allows you to undo the soft delete and recover the record.
toSqlPatch() Returns the SQL query string for updating data.
toSqlCreate() Returns the SQL query string for inserting single data.
toSqlDestroy() Returns the SQL query string for deleting single data.

CRUD Validation Functions

Function Description
skipValidation() Ignores all validation rules for inserts and updates.
setValidationRules() Sets or overrides existing validation rules for the model on the fly.
setCustomValidationRules() Adds or changes existing validation rules that are already set in the model.
setCreateValidationRules() Adds or changes existing validation rules for create operation only.
setPatchValidationRules() Adds or changes existing validation rules for update operation only.

Security Functions

Function Description
safeOutput() Escapes output to prevent XSS attacks. All data, including eager loaded and appended data, will be filtered.
safeOutputWithException() Same as safeOutput(), but allows specific fields to be excluded from escaping.

Helper Functions

Function Description
toArray() Converts the result set to an array format (Default).
toObject() Converts the result set to an object format.
toJson() Converts the result set to JSON format.
showColumnHidden() Displays hidden columns by removing the $hidden property temporarily.
setColumnHidden() Dynamically sets columns to be hidden, similar to Laravel's $hidden model property.
setAppends() Dynamically appends custom attributes to the result set, similar to Laravel's $appends model property.

All versions of codeigniter3-model with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package onlyphp/codeigniter3-model contains the following files

Loading the files please wait ....