PHP Classes
Icontem

Subject: Metabase - working example


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend!

      Metabase   All threads   Metabase - working example   (Un) Subscribe thread alerts  
Subject:Metabase - working example
Summary:working example with forms generation
Messages:10
Author:Rob Glasener
Date:2007-06-26 05:01:19
Update:2007-06-27 22:43:48
 

  1. Metabase - working example   Reply  
Picture of Rob Glasener
Rob Glasener
2007-06-26 05:01:19
It would be real nice to have working example of populating a form from data in a table using metabase

  2. Re: Metabase - working example   Reply  
Picture of Manuel Lemos
Manuel Lemos
2007-06-26 05:41:41
That is the purpose of this complementary class:

http://www.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.

http://www.phpclasses.org/formsgeneration

  3. Re: Metabase - working example   Reply  
Picture of Rob Glasener
Rob Glasener
2007-06-26 16:14:41
I 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.


  4. Re: Metabase - working example   Reply  
Picture of Manuel Lemos
Manuel Lemos
2007-06-26 17:06:43
Yes, first you need to add the inputs to the form. Then you use selectformvalues to load the input values from database query results.

  5. Re: Metabase - working example   Reply  
Picture of Rob Glasener
Rob Glasener
2007-06-27 04:07:12
well i am close but I got this error
Fatal 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

  6. Re: Metabase - working example   Reply  
Picture of Manuel Lemos
Manuel Lemos
2007-06-27 04:40:39
You need to set the database handle variable of the database access class.

$dba->database = $db->database

  7. Re: Metabase - working example   Reply  
Picture of Rob Glasener
Rob Glasener
2007-06-27 05:29:25
well 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

  8. Re: Metabase - working example   Reply  
Picture of Manuel Lemos
Manuel Lemos
2007-06-27 08:04:14
It looks Ok. Maybe you are missing a semi-colon in the previous line.

  9. Re: Metabase - working example   Reply  
Picture of Rob Glasener
Rob Glasener
2007-06-27 15:05:29
well 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


  10. Re: Metabase - working example   Reply  
Picture of Rob Glasener
Rob Glasener
2007-06-27 22:43:48
I 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.

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2008 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products