Git Product home page Git Product logo

amiss's Introduction

โš  NOTE: This has been rendered obsolete with the addition of native support for attributes in PHP 8. It will receive no further updates.

โš  ALSO NOTE: This repository will move from Github at some point in 2024.

---

Amiss - Stupid, Simple, Fast!

Amiss is a Data Mapper and Active Record implementation for MySQL and PHP 5.6 or greater.

Amiss does not try to be a fully-fledged ORM that cooks you breakfast, walks the dog and gives your schema its daily back massage, it only tries to take the monotony and repetition out of retrieving simple objects and simple relationships from a database that already exists.

Its not the fanciest ORM on the block, but its brutal simplicity may make it a better candidate for your next throwaway project or prototype than PHP's premier ORM behemoth Doctrine, the dated interface of Propel, or the tight coupling of your favourite framework's own model layer.

It is unapologetic about being stupid, simple and fast.

Documentation

See the doc/ folder for more info, or the example/ folder for some quickstarts. Visit http://k3jw.com/code/amiss/ for HTML docs and PDF downloads.

License

Amiss is licensed under the MIT License. See LICENSE for more info.

amiss's People

Contributors

shabbyrobe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

amiss's Issues

Auto column value support

AutoGuid demonstrates a hacky way to use identity based type handlers to generate values. It would be simpler to provide a dedicated means to generate values when none are present. This could also be used for slugs (i.e. "My Title" becomes "my-title")

Array mapper overwrites field name when applying default primary type.

Hi,

I believe there is a small bug with the Array mapper. When using a primary key with a property name different to the DB field name, if you do not specify the field type explicitly, the mapper sets the type to the default primary type. However, in doing this, it does not maintain the overridden property name, which eventually causes the query to fail with something like the following error:

Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'field list'' in C:\www\play\Amiss\Sql\Manager.php on line 567

I've attached a file that recreates the issue and what I believe is a modified Arrays file that will fix the problem. First time using Github and never used Git so not really sure what the process is for submitting fixes. Will probably have a go soon.

Recreate: http://pastebin.com/yMDEGX8F
Fix: http://pastebin.com/pJePjf9z
Both expire in 1 month.

Cheers
Steve

PS Really like your library, found it very useful for a few projects I'm working on. Thanks.

Updating join views causes exception

If you have a view that contains a join and an Amiss model that represents it, you can't perform updates because Amiss tries to set every column even if it hasn't changed.

PDOException' with message 'SQLSTATE[HY000]: General error: 1393 Can not modify more than one base table through a join view

This is an unavoidable consequence of Amiss eschewing dirty state tracking for performance, but there may be an API level solution to this problem I'm just not seeing yet.

ChainMapper to allow the use of multiple mappers at once

Splitting discussion from #14 into separate discussions. Paging @dig412.

ChainMapper to allow the use of multiple mappers at once - i.e. a stack that finds the top-most compatible mapper. I have Note at the bottom, and all our CustomMappers at the top.

Definitely want to see this one in there for v5, I have already got a place in my own code where it would be a benefit.

Order By support for getRelated

Related objects can be filtered by supplying a Criteria obects to the getRelated method, but ORDER BY clauses appear not to be supported.

The runQuery method in Amiss\Sql\Relator\OneMany assumes that if criteria are supplied then there are only WHERE conditions to satisfy.

Can this be fixed by adding support for the various kinds of criteria in the runQuery method?

Many-to-Many with field/column name mismatch

I'm trying out Amiss as a replacement for an in-house ORM that has reached its end of life, and it's working brilliantly so far.

I've run into a problem with many-to-many relationships when the field name of an entity does not match the column name.

For example:

class Artist
{
    /**
     * @primary
     * @field artistid
     */
    public $id;

    /** @field */
    public $name;

    /**
     * @has.assoc.of Event
     * @has.assoc.via EventArtist
     */
    public $events;
}

class Event
{
    /**
     * @primary
     * @field eventid
     */
    public $id;

    /** @field */
    private $name;

    /** 
     * @has.assoc.of Artist
     * @has.assoc.via EventArtist
     */
    public $artists;
}

I've tried to use the functionality from one-to-one mapping for specifying alternate names (http://k3jw.com/code/amiss/doc/relations.html#one-to-one-relator), but although the annotations are parsed correctly, the join does not work.

class EventArtist
{
    /** @primary */
    public $eventId;

    /** @primary */
    public $artistId;

    /**
     * @has.one.of Event
     * @has.one.on.eventId id
     * @var Amiss\Demo\Event
     */
    public $event;

    /**
     * @has.one.of Artist
     * @has.one.on.artistId id
     * @var Amiss\Demo\Artist
     */
    public $artist;
}

$event = $manager->getById("Event", 1);
$manager->assignRelated($event, "artists");
Exception:
Field id does not exist against relation for Event

I can make this work by giving the Event and Artist classes $eventId and $artistId fields, but I'd like to keep just $id if possible.

Is there a way to do this?

MySQL server has gone away

Splitting discussion from #14 into separate discussions. Paging @dig412.

MySQL dropping the connection after inactivity [...] was biting us in some long-running scripts

This old chestnut! Love to see what you have here, I dread this error.

I've factored out the Connector component into shabbyrobe/pdok. Does this issue belong in that project?

Manager should use primaries of Object attributes when saving

#24 When I try to save an entity having a field related to another table (using the @has.one.of clause) I get an Exception because my object is not a valid type.

Manager should check if the value is an object, and if so if the underlying class has a meta in order to use its primary value.

This in order to avoid painful temporary settings, like:

$temp = $entity->getUser();
$entity->setUser($temp->getId());
$manager->save($entity);
$entity->setUser($temp);

@shabbyrobe do you think this kind of request makes sense ?

Extendable Criteria object for building DSLs to find particular entities

Splitting discussion from #14 into separate discussions. Paging @dig412.

I've got something similar that I've been working on for this as well, but it's not ready for prime time. I'll clean it up a bit and post it as a gist some time in the next week or two. It might be interesting to see if we can combine the ideas we've had separately.

MySQL: Support for DELETE IGNORE

Splitting discussion from #14 into separate discussions. Paging @dig412.

This one I'm not quite so sure about. What errors does DELETE IGNORE ignore? Does it still error out on foreign key constraints? I would be reluctant to add it in if it didn't. Can you please provide more details on the use case?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.