Download the PHP package bancer/native-sql-mapper without Composer

On this page you can find all versions of the php package bancer/native-sql-mapper. 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 native-sql-mapper

native-sql-mapper

A lightweight extension for the CakePHP ORM that converts native SQL queries (executed through prepared PDO statements) into fully hydrated CakePHP entity graphs.

This library allows you to execute raw SQL while still benefiting from CakePHP’s entity system, associations, nested structures, and conventions. It supports deep associations, belongsToMany relations, junction data, nested mapping, and strict alias validation.

native-sql-mapper is ideal when:

Aliases such as:

will be converted into a fully hydrated entity objects.


🚀 Features


📦 Installation

Install via Composer:


🔧 Setup & Usage

1. Import the trait in your Table class

2. Use the trait

3. Example usage

$entities now contains hydrated Article entities based on the SQL result.


🔁 hasMany Example Using Minimalistic SQL

$entities now contains an array of Article objects with Comment objects as children.

Same as the result of reqular ->find()...->toArray():

Notice that FROM and JOIN clauses may use short or long aliases or no aliases at all (if the query does not use 'hasMany' or 'belongsToMany' associations) but all fields in SELECT clause must use aliases according to CakePHP naming convention {Alias}__{field_name}.

🔁 belongsToMany Example

You can find more examples in tests - https://github.com/bancer/native-sql-mapper/tree/develop/tests/TestCase/ORM.

Mapping


🧠 How It Works


➕ BONUS: IN() placeholder helper for native SQL

When working with native SQL queries in CakePHP, PDO does not support binding arrays directly to IN (…) clauses. Each value must be expanded into its own placeholder and bound individually.

The InPlaceholders class provides a small, explicit helper that removes this boilerplate while keeping native SQL fully transparent and predictable.

What it does

InPlaceholders is a value object that:

There is no ORM magic involved — this works purely at the native SQL / PDO level.

Basic example

⚠️ Requirements


📝 Notes & Limitations


✔️ Summary

native-sql-mapper gives you the freedom of native SQL with the structure of CakePHP entities.
It fills the gap between raw PDO statements and the ORM — allowing complex SQL while preserving the integrity of your entity graphs.



All versions of native-sql-mapper with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4.0
cakephp/database Version ^4.0|^5.0
cakephp/orm Version ^4.0|^5.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 bancer/native-sql-mapper contains the following files

Loading the files please wait ...