lessql icon indicating copy to clipboard operation
lessql copied to clipboard

Add discovery

Open morris opened this issue 10 years ago • 2 comments

@rubenvincenten suggested adding auto-discovery of keys for engines like InnoDB that support meta-information.

morris avatar Sep 03 '15 18:09 morris

Just wrote this little snippet: https://gist.github.com/rubenvincenten/78963552b6da0045b5e4bd99d243ceb0#file-convention-php

If a ConventionAdapterInterface with getPrimaryKey, getReferencingColumn and getBackReferencingColumn could be added that'd be great :)

In __construct you'd add a second parameter typehinted by that interface. If that parameter would be null, you could make the $convention_adapter use a default lessql convention. The functions in lessql\database would then consult $this->convention_adapter instead of using properties that can be modified by setter methods.

This would also add options like support for chain of responsibility adapters.

Langmans avatar Apr 28 '16 19:04 Langmans

API-wise, I believe discovery should be more like $db->discover( $options ) which would figure out the columns and set them using the existing API. This way you can combine discovery and custom settings, plus there's no need for another interface. PRs welcome!

morris avatar May 26 '16 16:05 morris