Download the PHP package mattvb91/lightmodel without Composer

On this page you can find all versions of the php package mattvb91/lightmodel. 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 lightmodel

LightModel

What is LightModel?

The LightModel ORM is test project to build an ActiveRecord style implementation from scratch.

Using this in a live project is not recommended. Please look at Eloquent or Zend Model for a robust and highly tested solution.

Usage

To initialize LightModel you need to call and pass your instance of PDO to it.

You can also pass in an optional array for further configuration. For example:

Currently the typecast option is the only option available. If used this will typecast Integer columns defined in your MySQL database to be an integer attribute on your model.

To get started with a model, your class needs to extend

Creating a Model

You will need to implement the function in which you define a key value array for the values associated with your columns.

For example a basic table with with the following structure could be represented like this:

You do not need to manually bind the primary key column if it is set up as an auto increment value in your DB.

You can of course use your normal getters to access your column values too inside the method as long as you bind it to your correct column.

To create a new row on your user table you would use the following:

To override the table name or table key simply implement the following in your class:

Fetch a row by key

To fetch a row by its key use the static on the class you want to fetch. For example:

Check a model exists

To check if a model actually exists in your database you can use the method.

Refresh a model

You may run into situations where you need to fetch the latest version of your row again. Use the method to update your current model.

Keep in mind this will set your model back to whats currently in your DB.

Delete a model

To delete a model simply call the method:

Relationships

BelongsTo

To define a Belongs to relationship use the method in your model. For example if our User is associated with a Department you could do the following inside your User class.

Once a relationship has been queried once any further accesses to not hit the database again.

Fetching multiple rows

To fetch multiple rows simply use the method.

Filtering

You can also filter data sets by passing an optional array int the method. You must pass the correct table column name.

Optionally you can also pass in the operator you want to perform. The order MUST be Table_Column => ['Operator', 'Value']

To set the order or limit the results returned you can make use of the and constants and pass them in your options array:

Fetching keys

You may sometimes run into situations where performing a brings back too large of a resultset. You can instead perform the same filters using which instead of returning an array of fully loaded Models it will now only return the unique column ID's that fit your filtered criteria. You can then use that ID to individually load the full model manually:


All versions of lightmodel with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
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 mattvb91/lightmodel contains the following files

Loading the files please wait ....