Php database object framework

PHP Object Oriented SQL Framework

This is a framework for building SQL queries (SELECT, UPDATE, INSERT, DELETE) in an object-oriented way. The generated query (it really is just a string) can then be used with any type of database access layer. (ie. MDB2).

Project Activity

Categories

License

Follow PHP Object Oriented SQL Framework

Find and apply for remote jobs and jobs in your area

Find the next step in your career. Find and apply for remote jobs and jobs in your area using the Slashdot Job Board. Browse by job, company, location, and more.

User Reviews

Additional Project Details

Intended Audience

Programming Language

Database Environment

Registered

An entity framework for Go. Simple, yet powerful ORM for modeling and querying data. Simple API for modeling any database schema as Go objects. Run queries, and aggregations and traverse any graph structure easily. 100% statically typed and explicit API using code generation. The latest version.

JavaScript UI library and framework for speeding up web development. JS Framework for cross-platform web Apps development 102 UI widgets and feature-rich CSS / HTML5 JavaScript controls. Save at least 3000+ development hours by using ready-made widgets and UI controls. Develop Web UI 30% faster.

Kendo UI is the ultimate collection of JavaScript UI components with libraries for jQuery, Angular, React, and Vue. Quickly build eye-catching, high-performance, responsive web applications—regardless of your JavaScript framework choice. Easily add advanced JavaScript components into your.

Источник

Atlas

Atlas is a database framework for PHP to help you work with your persistence model, while providing a path to refactor towards a richer domain model as needed.

Object-Relational Manager

A data mapper ORM for your persistence layer, not your domain layer. The flagship package in the Atlas family. Supports MySQL, PostgreSQL, SQLite, and SQL Server.

Skeleton Generator

A command-line interface to generate all of the necessary Atlas classes to model your existing database tables in PHP. Supports MySQL, PostgreSQL, SQLite, and SQL Server.

Data Mapper

The core of the Atlas.Orm package, the data mapper helps you define relationships between table data gateways so you can retrieve Record objects with all their related rows. Supports MySQL, PostgreSQL, SQLite, and SQL Server.

Читайте также:  Javascript get event name

Table Data Gateway

A table data gateway implementation, for when a full-fledged persistence ORM seems too much. Supports MySQL, PostgreSQL, SQLite, and SQL Server.

Query System

Build and perform SELECT, INSERT, UPDATE, and DELETE queries through a fluent interface using standard SQL vocabulary. Supports all database drivers for PDO.

PDO Wrapper

A straightforward PDO connection wrapper to provide convenience methods for fetching and yielding database results. Supports all database drivers for PDO.

Why Atlas?

Atlas helps developers to get started about as easily as they would with Active Record for their persistence model, and provides a path to refactor more easily towards a richer domain model as needed.

What Is A Persistence Model?

A persistence model is a model of your database, not your business domain. More specifically, it is an object-oriented representation of the tables and rows in the database.

Very often, a developer does not have a good, clean domain model to work with, especially early in the project. But there is almost always a database of some sort. Atlas models that database structure so you can use it more easily in PHP code.

Why Use A Persistence Model?

A persistence model alone should get your application a long way, especially at the beginning of a project. The Row, Record, and RecordSet objects in Atlas are disconnected from the database, which should make the refactoring and integration process a lot cleaner than with Active Record.

Because Atlas works with your database schema as-it-is, and not as-the-ORM-thinks it-should-be, Atlas is a very good fit for projects with pre-existing databases. (Indeed, Atlas supports both composite primary keys and composite foreign keys — for some legacy systems, composite keys are absolutely necessary.)

How Does Atlas Work?

At a high level, Atlas is mini-framework built from a stack of packages, where any «lower» package can be used indepdendently of the the ones «above» it. This means you can pick the exact level of functionality you need right now, and expand to the next greater set of functionality only as is becomes necessary.

The package hierarchy, from bottom to top, looks like this:

  • Atlas.Pdo provides a database Connection object and a ConnectionLocator. If all you need is convenience wrapper around PDO with fetch and yield methods, this is the package for you.
  • Atlas.Query is a query builder that wraps an Atlas.Pdo Connection. If you just want to build and perform SQL queries using an object-oriented approach, the Atlas query objects can handle that.
  • Atlas.Table is a table data gateway implementation that uses Atlas.Query under the hood. If you don’t need a full data mapper system and only want to interact with individual tables and their row objects, this will do the trick.
  • Atlas.Mapper is a data mapper implementation that models the relationships between tables. It allows you to build Record and RecordSet objects whose Row objects map naturally back to Table objects; you can write them back to the database one by one, or persist an entire Record graph back to the database in one go.
  • Atlas.Orm is the overarching ORM package; it provides a convenience wrapper around the Mapper system, as well as several strategies for transaction management.
Читайте также:  Nx draw python параметры

Thus, Atlas uses a table data gateway for the underlying table Rows, then composes those Rows into Records and RecordSets via a data mapper; the PDO connection and query system move the data back and forth between PHP and the database.

From Persistence To Domain

At the beginning, your domain logic layer (e.g. service layer, application service, interactor, use case, etc.) can manipulate the Atlas persistence objects (Records and RecordSets) directly. You can add simple behavior methods to your Records and RecordSets as well.

Then, as a domain model grows within your application, Mehdi Khalili shows that the refactoring process can move along one of two paths:

  • «Domain Model composed of Persistence Model». That is, the domain objects can use Atlas persistence model Record objects internally, but do not expose them. The domain objects can manipulate the persistence model objects internally as much as they wish. For example, a domain object might have a getAddress() method that reads from the internal Record.
  • «DDD on top of ORM». Here, Repositories map the persistence model objects to and from domain objects. This provides a full decoupling of the domain model from the persistence model, but is more time-consuming to develop.

Other Considerations

Here some further considerations regarding Atlas:

  • PHPStorm IDE auto-completion. When you use the phpstorm.meta.php resource included in relevant packages, PHPStorm will autocomplete methods and properties from your Mapper, Record, RecordSet, et al. classes.
  • No annotations. Code should be in code, not in comments.
  • No lazy-loading. Lazy-loading is seductive, but eventually is more trouble than it’s worth. Atlas doesn’t make it available at all, so it cannot be invoked accidentally.
  • No data-type abstractions. Data-type abstraction seems great at first, but it too ends up not being worth the trouble. Therefore, the actual underlying database types are exposed and available as much as possible.

Contra-Indications

You may not find Atlas suitable for your needs because of the following:

  • Atlas uses code generation, though only in a very limited way. It turns out that code generation is useful for some boilerplate code. For example, each table is described as a PHP class, one that returns things like table name, column names, etc. Since the table class should change only when the database changes, code generation makes sense here; however, some developers may be against code generation just on principle alone.
  • Atlas uses base Row, Record, and RecordSet classes, instead of plain-old PHP objects. If this were a domain modeling system, a base class would be unacceptable. Because Atlas is a persistence modeling system, base classes are less objectionable, but for some this may be undesired.
Читайте также:  What is binary file in java

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

php framework for database communication

Stefterv/dbObject

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

dbObject is a single file php library that will allow you to easily communicate with the database and send new data to the database

The id variable is automatically added.

Getting rows out of the database

Get stuff out of the database by query

Get a single object out of the database

Get all rows out of the database

Putting data in the database

You can put an array into a object with: Object->update(array);

$array = array("input"=>"test","test"=>"1"); $object = Object::findByID(1); $object->update($array); 

Now the object’s are updated but, it is not yet submitted to the database. To send the current state of the object to the database use $object->submit();

$array = array("input"=>"test","test"=>"1"); $object = Object::findByID(1); $object->update($array); $object->submit(); 

Creating new stuff in the database

Creating a new row is as easy as creating a new object: $object = new Object(); then submit it to the database with: $object->submit();

$array = array("input"=>"test","test"=>"1"); $object = new Object(); $object->update($array); $object->submit(); 

Removing rows from the database

remove stuff from the database is as simple as

Источник

Оцените статью