S
S
StrangeAttractor2014-11-24 04:10:24
PHP
StrangeAttractor, 2014-11-24 04:10:24

What PHP ORM can handle natural keys without auto-increment IDs?

In many cases, from the point of view of the relational model, synthetic auto-increment IDs are heresy. For example, in a table of books, it is natural to use ISBN as a primary key, in tables of languages ​​/ countries / currencies, etc. - ISO codes, for many entities for which there are no standards, it can be convenient to come up with your own "standard" of convenient human-readable identifiers in order to preserve the ability to conveniently perform complex operations on data using SQL. In addition, it is not uncommon for the most logical record identifier to be a composite key. Other languages ​​have ORMs that are quite suitable for dealing with such cases, for example, the same Entity Framework for .Net. Are there similar ORMs for PHP?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2014-11-24
@SilenceOfWinter

Doctrine for example, but in general, almost every PHP framework has its own implementation. Autoincrement is set at the DB level (in mysql at least), just make changes to the table structure. Regarding the use of ISBNs, etc. as a primary key: in mysql it is recommended to use numeric types for field data because indexes in this case work faster (roughly speaking: search in an associative array is slower, more overhead data).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question