Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Can someone explain how to use the database?

edited October 2006 in Vanilla 1.0 Help
I have gotten far enough to get the table onto vinilla (for my extension) but I am clueless on how to manage and display it, can someone please explain this to me?

Lets say I want to add to the comment query so that it will check to see if the users ID matches up the commentors ID.

Lets say I want to make a query from scratch what do I do?

Comments

  • Options
    Do you know any mysql whatsoever or are you just unsure how to use the sqlbuilder class that vanilla uses?
  • Options
    I am unsure about the sql builder I have alot ot MYSQL expirence.
  • Options
    edited October 2006
    There are lot's of examples in the libray/Vanilla folder. But basically you use these methods:

    Create a new instance of the SqlBuilder class:
    $s = $Context->ObjectFactory->NewContextObject($Context, 'SqlBuilder');

    Set the main table of which you want to retrieve data. Use 'd' as an alias:
    $s->SetMainTable('Discussion', 'd');

    Add some fields to the select statement you want, again specify the alias:
    $s->AddSelect(array('DiscussionID', 'Name'), 'd');

    Now we add a where-statement and an order by property:
    $s->AddWhere('d', 'DiscussionID', '', '10', '<'); $s->AddOrderBy('DiscussionID', 'd');

    Finally, to retrieve the data, use the Database object:
    $ResultSet = $Context->Database->Select($s, 'Name of your class', 'Function where this query is triggered', 'Some error information');

    The result can be looped through by using:
    while ($row = $Context->Database->GetRow($ResultSet)) { echo $row['Name'] . '<br />'; }

    But again.. if you want to learn it, just browse through the vanilla files, or take a good look at the SqlBuilder class ;)
This discussion has been closed.