Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorasejua
    • CommentTimeDec 6th 2007
     
    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
    • CommentTimeDec 6th 2007
     

    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
    • CommentTimeDec 6th 2007
     

    "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
    • CommentTimeDec 6th 2007
     
    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
    • CommentTimeDec 6th 2007
     

    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
    • CommentTimeDec 6th 2007
     
    Good to know ^_^

    Thanks again Kaste.
Add your comments
    Username Password
  • Format comments as