Download the PHP package gyde/mysql-object-model without Composer

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

MySQL-Obejct-Model

A PHP Object Model using MySQL as backend via PDO. Allows fast scaffoling of Models with a high performance MySQL specific backend. First version is available, then more information regarding installation, use and namespacing will follow. Memcache and Static cache has been added for MOMBase and MOMSimple

Table of Contents

  1. Version
  2. Usage
  3. Classes
  4. Caveats
  5. Tools

Version

This version is considered stable and will be version tagged 1.0 once its been field tested with php7.3!

Current projects using this project:

No guareentes are given when using this code, but all suggestions and bugreports are welcome.

Usage

Example table

Class definition

A simple example on the usage of MOMSimple

You only need to define the optional columns you want to use for easy (constant safe) access, object member variables will be created from database table definition using SQL lookup.

Connecting SQL using PDO

Creating and saving objects

Get object by primary key

Fetching objects

All

Filtering

A small guide to filtering using where clauses on many or one object

Many

Fetch some User objects by SQL where clause

Functionality like the above example should in general be placed inside the object class like so:

One

Fetch one User object by SQL where clause

Modifying object

When fetching objects

You can overwrite the default load method to change member variables after an object is fetched from the database, you might want to "cast" all timestamps and datetimes into DateTime objects

Classes / Types

MOMBase.class.php

The generic / factory class which all object models extends from. This contains generic query function and requires that extending classes implements needed methods.

MOMSimple.class.php

A simple scaffoling class for MySQL tables with ONE column as primary key

MOMCompound

A compound scaffoling class for MySQL tables with SEVERAL columns as primary key

Caveats

Here is a list of common tips, tricks and caveats currently in the MOM system.

On update / default value columns

If you create a table with a column that has a default "current timestamp" value or "on update" property beware that this column is controlled completely by MOM and can't be updated by setting a value on public class variable. The column is omitted from any insert or update statements that MOM performs.

Tests (PHPUnit)

Tests has been designed using PHPUnit and will create and droppe tables as needed within the docker env. In order to run the tests, the following needs to be satisfied:

Build the docker environment using ./docker/build_container ./docker/bootstrap_container /absolute/path/to/MySQL-Object-Model/

Run ./run_tests to start the tests within the docker env. ./run_tests

build_mom

Shell script to "build" MOM using first provided argument as namespace.

MOM files will be placed in a folder called build with namespace my\name\space. Additional slashes are needed due to shell escaping


All versions of mysql-object-model with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4.0 || ^8.0.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 gyde/mysql-object-model contains the following files

Loading the files please wait ....