Code Monkey home page Code Monkey logo

orm's People

Contributors

mathcals avatar qurben avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

brussee

orm's Issues

Choose license

Packagist requires us to choose a license (or mark as proprietary) in order for further updates to process.

License "Unknown" is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.
If the software is closed-source, you may use "proprietary" as license.

Serialize into object

Add the option to save a simple PHP object into the database. For instance creating a simple Email object which can only contain a valid email address.

Such class would look something like the following:

class Email extends PersistenceObject {
  /** @var string **/
  protected $email;

  /**
   * @param string $email;
   */
  public function __construct($email) {
    $this->assertValidEmail($email);
    $this->email = $email;
  }
  
  public function getValue() {
    return $this->email;
  }
}

abstract class PersistenceObject {
  abstract public function __construct($value);
  abstract public function getValue();
}

The objects should require one required constructor argument and implement the getValue method.

When defining a model the definition would look something like:

protected static $persistent_attributes = [
  'email' => [T::Object, true, Email::class],
];

Or just, where the orm checks if the type is instantiable (subclass of PersistenceObject)

protected static $persistent_attributes = [
  'email' => [Email::class],
];

Validate PeristenceModel::retrieveByUUID

There is no validation whatsoever in this method, there should be, this can help catch bugs easier.

Number of primary keys should be validated.

Table part in uuid should be validated.

Move to PHP 7

With csrdelft/csrdelft.nl running on PHP 7.0 we can move this project to PHP 7 too.

New stuff to use in PHP 7

  • (scalar) Typehints
  • Return types
  • Null coalescing
  • Grouped use (not a fan personally)

Enum instance

An Enum should not represent a choice itself.

public function getChoice() {

$this->order[] = $column . ' ' . $direction->getChoice();

In the usage example above, I think, it is better to create an OrderDirectionsEnum (plural) with options of OrderDirection (singluar) if you want, or just integer/char/string.

Sql join

Make it possible to create joins in sql to retrieve a bunch of data at once.

Multilevel database transactions

With MySql SAVEPOINTs it is possible to create multilevel database transactions.

After setting a savepoint you can rollback to that savepoint while you are still in a transaction.

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.