You are here: Re: QuickFom question RESOLVED « PHP Programming Language « IT news, forums, messages
Re: QuickFom question RESOLVED

Posted by IchBin on 08/10/06 20:16

IchBin wrote:
>
> I am new to PHP. I am trying to create a QuickForm Select element and
> load it from a database with 'HTML_QuickForm::LoadQuery'.
>
> I figured it would be a lot easier than build all of that code by hand.
> The only thing is I can not find much info on using these objects. I can
> not read the manual for this as I can for Java API's. I am able to
> display the Select object with label but no data.
>
> Can some one point me in the right direction? I am missing something
> stupid..
>
> This is the code sniplet:
>
> $form = new HTML_QuickForm();
> $s =& $form->createElement('select','name','Catagory:' );
> $s->loadQuery($conn, 'select id, name from catagory order by name',
> 'name', 'id');
> $form->addElement($s);
> $form->display();

Well for what it's worth. I figured out why I could not get
'HTML_QuickForm::loadQuery' to work but able to get
'HTML_QuickForm::loadDbResult' working.

The api specs states for a 'loadDbResult' that I should use DB_result
object for the first parameter. So this was no problem because I did all
of the db work and passed the result.

The api specs states for a 'loadQuery' that I should user either
an existing DB connection or a valid dsn for the first parameter. Well I
got in to my head to use the $dsn var. Well I kept that var in another
php file 'config.php'. So come time to use it, even having an include
for that file, the running php script could not find it.

It seems that using a $dsn for 'loadQuery' requires that the $dsn be
defined in the script that references it. So once I saw this, I said
hell with that and just used the $db object. Which is nice because I was
not using the DB abstraction when I first tried using 'loadQuery'. I
added to work with 'loadDbResult'.

Conclusion for me is that when there are a lot of <Select> items with
one or mores <Select> objects on a form, this is perfect. Not sure what
the extra overhead is for this 'user friendly coding' is but can't be
much for this abstraction...

$s =& $form->createElement('select','name','Category:' );
$s->loadQuery($db, $category_dropdown_select);
$form->addElement($s);

Again, I am new to this php scripting lang stuff. Just trying to get my
feet wet!

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация