Engines Aether Legend of the Lunar Priest NIFE Roadmap
Shatterloop Game Projects Deprecated Starwright
Saepes Mundi Other Projects Blog  

Game Projects

ASD

Posted August 3, 2024 by Xhin



There are 4 Replies


Syntax v2

There's some contradictions to the above syntax, so here's a better primer:

Result Types

  • ASD::forum(7) -- pulls a single row where the primary key is 7, assuming it's defined.

  • ASD::forums()->by_category('games') -- pulls multiple rows where the category is games.

  • ASD::forums_slug()->is('on_ql') -- pulls slugs from the forum databases in a column, based on the trait on_ql being true. This kind of thing doesn't require a definition, and also doesn't use it -- it knows which database to query and what to use as the select via the magic name.

    In any case, the result type is dictated by the format of the first function within the chain.

    Method overloading

    The first function's arguments typically describe a primary key:

  • ASD::forum(7) -- gets a row by the primary key = 7.

  • ASD::profile(7,17) -- same here but works with primary keys that are assigned multiple fields.

    Wildcards can also be assigned:

  • ASD::profiles(7) -- the default behavior is pulling all rows assigned to uid = 7.

    FGH syntax can also be used as an argument -- can be either at the beginning or the end of the rest of the arguments, doesn't matter. FGH syntax is a string that starts with #. If you need to use a literal #, you can use ## or just assign a different symbol to ASD temporarily or permanently. Doubling here also works with assigned symbols. (There's a function to literally make a change for only the next query).

  • ASD::stats(10,'#name=value') -- Fetches stats by first key = 10, and then pairs name to value.

    Clauses

    An ASD statement contains exactly one static method and an optional 1 clause. Clauses have magical syntax and narrow down a selection of the table in some easy-to-use way.

  • is() and not() -- int(1) fields that are either 1 or 0. For example ASD::threads()->not('locked'). Multiple conditions are supported by overloading the method.

  • by_X(Y) -- equivalent to ->where(X,Y). Can be overloaded for an AND query on the values.

  • by_a_X(Y) -- same as the above, but explicitly has more than one value (or it'll return an error) and is instead an OR query.

    This magic method also supports:

  • by_X_and_Y(Xval,Yval) -- multiple fields targeted, with an AND query.

  • by_X_or_Y(Xval,Yval) -- same here, but uses OR.

    These can be extended further:

  • Multiple ands or ors for 3+ fields. Using both and + or returns an error.

  • _a_ can also be used in one or more fields, for example by_slug_and_a_sticky(x,[Z]) runs an AND clause with an embedded or clause.

  • For embedding an AND clause inside an OR clause, just use _by_ again, like by_name_or_by_value() runs a parent OR clause with the second argument being an array which is an AND clause.

    but_X() clauses

    Definitions can assign conditions to a query. You can override this with the but() clause:

  • but_value(7) -- overrides value to 7 if it was previously defined.

  • but_no_X() -- overrides the X part of the where condition entirely.

    Should support multiple things here with a longer statement.

    ZXC integration

    ASD methods can't overlap with ZXC ones. You can use ZXC methods from within ASD:

  • ASD::forums()->like('name','the')

    If you want a longer chain, use find_ prefix before the static method. You then have to manually close with one of the ZXC return values.

  • ASD::find_forums()->like('name,'the')->like('slug','the')->go()

    The ZXC return type takes precedent over the ASD static method syntax, so forum()...->go() will return multiple entries.

  • October 24, 2024
    Xhin
    Sky's the limit

    NOTE

    The syntax shouldn't change with pluralization -- the result set should instead either change the syntax or be obvious via context of the syntax used.

    November 17, 2024
    Xhin
    Sky's the limit

    Write functions

    ASD::kill_threads(7)

    ASD::add_forums({}) (will also return the insert id)

  • make_X, stop_X and toggle_X clauses affect int(1) fields, for example make_locked() or stop_sticky(). Assuming there needs to be a change_ prefix in the first method

  • November 17, 2024
    Xhin
    Sky's the limit

    extend and cease

    ASD::extend(X) will allow you to assign ASD or ZXC commands globally to all future ASD commands, while ASD::cease() will stop it.

    While this can form a code block (or be global if you never cease it) you can also assign a name to X in which case you can call upon it later via ASD::context(X)

    November 17, 2024
    Xhin
    Sky's the limit

    Reply to: ASD

    Username
    Password