Download the PHP package osemk/php-custom-model without Composer

On this page you can find all versions of the php package osemk/php-custom-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 php-custom-model

PHPCustomModel

PHPCustomModel let's you to convert your MYSQL database tables to a PHP Model automaticly. This library uses mysqli to connect and to request database.

FAQ

  1. Can I run PHPCustomModel for all MYSQL tables?
    • I tried to adopt it to use for all MYSQL tables but it can gives error with tables with non-PRI keys or tables has less identifier columns.

Getting Started

Before you start using this Library, you need to know how PHP works, you need to know how MYSQL work and what is Models. This is a fundamental requirement before you start. Without this knowledge, you will only suffer.

Requirements

Installing PHPCustomModel

PHPCustomModel is installed using Composer.

  1. Run composer require osemk/php-custom-model. This will install the latest stable release.
  2. Include the Composer autoload file at the top of your main file:
    • include __DIR__.'/vendor/autoload.php';
  3. Make models!

Basic Example

Documentation

PHPCustomModel converts tables to models. A sample database table that name is "employees"

id firstname jobtitle
1 Diane President
2 Mary VP Sales
3 Jeff VP Marketing
4 William Sales Manager (APAC)
5 Gerard Sale Manager (EMEA)

Using PHPCustomModel we can easily convert this table to a model and we can easily do CRUD processes on table like below.

Bring table

This will fetch row with ID =1 and assign columns to $employee var.

We can check if has a record with ID=1,

Check records

Now the current object includes these; id=1, firstname=Diane, jobtitle=President

We can change these parameters using model easily like below;

Change parameters

or

and update it;

Update

Now our table looks like below;

id firstname jobtitle
1 Angel New President
2 Mary VP Sales
3 Jeff VP Marketing
4 William Sales Manager (APAC)
5 Gerard Sale Manager (EMEA)

That is it!

If you want to delete record, use;

Delete

Now our table;

id firstname jobtitle
2 Mary VP Sales
3 Jeff VP Marketing
4 William Sales Manager (APAC)
5 Gerard Sale Manager (EMEA)

That is awesome!

Insert New record

Inserting a new row is also easy, just don't send an ID like below,

$employee = new CustomModel("employees",0);

It creates new model from scracth. Now you can add some strings

Now our table look like below;

id firstname jobtitle
2 Mary VP Sales
3 Jeff VP Marketing
4 William Sales Manager (APAC)
5 Gerard Sale Manager (EMEA)
6 Onur King of the World

Other fetching methods

You can fetch directly using other columns except ids.

it directly fetches id=6 but this column is not an identifier may be there are some records too, so it fetches only latest "Onur" record.

So you can make more unique your request with adding extra columns like below;

Other easy method

The best method for this library is save() method. When you want to change or insert a record to table, you can use save().

So awesome, didn't it?

License

MIT License, © Onur Erginer 2023-present.


All versions of php-custom-model with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3
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 osemk/php-custom-model contains the following files

Loading the files please wait ...