Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorasejua
     
    Hi all,

    I'm (very) newb with akelos and I'm trying to to create my first application with it, but I've found a lil problem...

    When creating the myapp_installer.php file where I'd like to define that a field must be unique... I've guessed the way it works by doing

    $this->createTable("devices",
    "id,".
    "mac_address C(12) NOTNULL DEFAULT '000000000000' UNIQUE,".
    ...
    );

    But how I'd do if I wanted to set two fields like unique... for example having another table like this,

    $this->createTable("ipaliases",
    "id,".
    "device_id,".
    "ip_address,".
    ...
    );

    I want a device to have many Ip's but not duplicated ones (other device id would have same ip_address(es) as other device alias)
    I know how to do it manually creating the bd using indexes and unique but dunno how to solve it with akelos :P
    Obviously device would have many aliases and every alias would belong to one device (1:N)

    It's something I must define when creating the installer... or later in the controller?

    Thanks in advance and sorry 'bout horrible english ^^'
    • CommentAuthorKaste
     

    umm, I remember this was my first commit. you have to add the index after you've created the table.

    something like this:

    $this->addIndex('ipaliases','col_name_1, col_name_2 UNIQUE','optional_index_name');
    

    the columns to be indexed is a simple comma-seperated list. the third argument is optional.

    hope it works.

    • CommentAuthorKaste
     

    "mac_address C(12) NOTNULL DEFAULT '000000000000' UNIQUE,"

    instead of C(12) better use string(12), because it may be that we get rid of the adodb-layer.

    • CommentAuthorasejua
     
    Oh, great, works perfectly! :)

    I followed the conventions of the ADODB library guide link in the Booklink tutorial drives you to, so that's why I'm using C, I, T, etc...
    Didn't knew I can use 'string' :) Could I use other datatype names like 'integer' or 'datetime' too?

    Thank you so much.
    • CommentAuthorKaste
     

    you can use:

    integer or int, float, 
    datetime, date, timestamp, time, 
    text, string, 
    binary, 
    boolean
    

    I have implemented decimal/numeric but not commited to svn until now.

    • CommentAuthorasejua
     
    Good to know ^_^

    Thanks again Kaste.