This topic is locked

database fields

7/14/2009 11:54:11 AM
PHPRunner General questions
T
tkjerulf author

Hi im testdriving phprunner, to see if it suits my needs, so far I love it!
I created a list, and edit form for a table. But I have an unusually issue, I like to solve if possible.
I added a button to the Edit Form, clicking this button adds a new database column using an sql.
In short the user fills a new textbox with a name, clicks the button and an SQL similar to this:

ALTER TABLE myTable ADD userColumnname Integer is called.
Now my problem, how do I make phprunner, during "runtime" add this field for editing on the EDIT form?
any hints greatly appriciated!
Thanks

T

J
Jane 7/15/2009

Hi,
you can do the following:

  1. create custom view for this table on the Datasource tables tab,
  2. check off one field only on the add page for this view on the Choose fields tab,
  3. edit this page on the Visual Editor tab,
  4. process entered field name and run correct query in the Before record added event on the Events tab.

    Here is a sample:
    global $conn;

    $str = "ALTER TABLE myTable ADD `".$values["FieldName"]."` Integer.";

    db_exec($str,$conn);

    return false;