|  | 
  Rob Glasener - 2007-06-26 05:01:19It would be real nice to have working example of populating a form from data in a table using metabase
  Manuel Lemos - 2007-06-26 05:41:41 - In reply to message 1 from Rob GlasenerThat is the purpose of this complementary class: phpclasses.org/databaseaccess
Use it with Metabase and also with the forms generation class. The forms class even comes with nice plug-ins to implement AJAX controls that link select inputs with options from a database, and also auto-complete text inputs with values retrieved from a database query using Metabase on the server side.
 phpclasses.org/formsgeneration
  Rob Glasener - 2007-06-26 16:14:41 - In reply to message 2 from Manuel LemosI acutally downloaded thatand was looking at it. I am really new to this, where do you put the call to selectformvalues? Could it be right after your last AddInput to the form?
 Like I said I am still a little new this, so please forgive my lack of knowledge.
 
 
  Manuel Lemos - 2007-06-26 17:06:43 - In reply to message 3 from Rob GlasenerYes, first you need to add the inputs to the form. Then you use selectformvalues to load the input values from database query results.
  Rob Glasener - 2007-06-27 04:07:12 - In reply to message 4 from Manuel Lemoswell i am close but I got this errorFatal error: Call to a member function Query() on a non-object in /Library/WebServer/Documents/phpclasses/metabase/metabase_interface.php on line 28
 
 i was working off your example
 
 $error=MetabaseSetupDatabaseObject(array(
 "Type"=>"mysql",
 "User"=>"root",
 "Password"=>"software"
 
 ), $db);
 if($error!="")
 {
 
 echo "Database setup error: $error\n";
 exit;
 
 }
 $db->SetDatabase("test");
 MetabaseSetDatabase($db->database,"test");
 
 
 
 
 and then later in my code
 
 
 
 /*
 * Create a databaseaccess object.
 */
 $dba=new database_access_class;
 
 
 
 
 and then
 
 $error = $dba->selectformvalues(
 
 $form,
 "users",
 array(
 "id"=>"Integer",
 "user_name"=>"text",
 "name"=>"text",
 "password"=>"text",
 "reminder"=>"text",
 "email"=>"text"
 ),
 array(
 "id"=>"id",
 "user_name"=>"user_name",
 "name"=>"name",
 "password"=>"password",
 "reminder"=>"reminder",
 "email"=>"email"
 ),
 array(
 "id"=>"",
 "user_name"=>"*****",
 
 "name"=>"",
 "password"=>"",
 "reminder"=>"",
 "email"=>""
 ),
 " WHERE id = 1"
 
 );
 
 
 I am leaving something out i know
 
 Thanks
  Manuel Lemos - 2007-06-27 04:40:39 - In reply to message 5 from Rob GlasenerYou need to set the database handle variable of the database access class.
 $dba->database = $db->database
  Rob Glasener - 2007-06-27 05:29:25 - In reply to message 6 from Manuel Lemoswell i got a lot closer, but now I have an error in this line$error = $dba->selectformvalues(
 $form,
 "users",
 array(
 "id"=>"Integer",
 "user_name"=>"text",
 "name"=>"text",
 "password"=>"text",
 "reminder"=>"text",
 "email"=>"text"
 ),
 array(
 "id"=>"id",
 "user_name"=>"user_name",
 "name"=>"name",
 "password"=>"password",
 "reminder"=>"reminder",
 "email"=>"email"
 ),
 array(
 "id"=>"",
 "user_name"=>"",
 "name"=>"",
 "password"=>"",
 "reminder"=>"",
 "email"=>""
 ),
 " WHERE id = 1"
 
 );
 unexpected T_VARIABLE in /Library/WebServer/Documents/samples/users_form.php on line 361
 
 am i missing a paren in there? I am never really sure where this error comes from
 
 You have been a tremendous help
 
 Thanks again
  Manuel Lemos - 2007-06-27 08:04:14 - In reply to message 7 from Rob GlasenerIt looks Ok. Maybe you are missing a semi-colon in the previous line.
  Rob Glasener - 2007-06-27 15:05:29 - In reply to message 8 from Manuel Lemoswell you were right, I was missing a semi colon on the previous line. I put that in, and now the form is being displayed but the values from the record are not there. I call to the metabase query on the previous line and got the fields returned, so I think I am still doing something wrong.The from that I am displaying is basically form_body.html.php from your templates directory.
 Almost there.
 
 Thanks again
 
 
  Rob Glasener - 2007-06-27 22:43:48 - In reply to message 8 from Manuel LemosI figured it out, I had lowercase on types of fields - thanks a lot. But I am sure more questions will follow. Great set of classes you have written. |