php-general Digest 28 Oct 2009 16:20:17 -0000 Issue 6415
Topics (messages 299416 through 299434):
Re: Converting tables into forms
299416 by: Robert Cummings
299421 by: Tony Marston
299422 by: Ashley Sheridan
299425 by: Shawn McKenzie
299427 by: Bob McConnell
299428 by: Bastien Koert
299432 by: Jay Blanchard
Re: What would stop header("Location...) from working?
299417 by: Mark Cilissen
299418 by: Mark Cilissen
Re: How to Get the Sub Classes of a Parent Class
299419 by: David Otton
299420 by: David Otton
Re: Netbeans IDE 6.5
299423 by: Bob McConnell
299430 by: Tom Calpin
Re: Converting MySQL into Form
299424 by: Jay Blanchard
299426 by: Jay Blanchard
Help with my first recursion menu
299429 by: MEM
PHP String convention
299431 by: Nick Cooper
299433 by: Jay Blanchard
299434 by: Jim Lucas
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
[email protected] wrote:
I am trying to take MySQL tables and use the table structure to create
HTML/PHP forms in as few steps as possible for further development. I
have a project that has hundreds of tables and requires hundreds of
forms to be created and don't want to do so field by field by hand.
With hundreds of tables, if you don't find an existing solution that
meets your needs, it sounds like it would be a good idea to design your
own anyways.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--- End Message ---
--- Begin Message ---
Try the Radicore framework at http://www.radicore.org This will allow you to
import your table definitions into its Data Dictionary, export those
definitions to produce table classes, then you can generate the basic
maintenance tasks using transaction patterns. This takes 5 minutes per
table, and you don't have to write any code - no PHP, no HTML, no SQL. You
even get an RBAC system so that you can run the transactions of a menu, and
decide which users have access to which tasks. There is also an inbuilt
Audit Logging system (which does not use database triggers) and a Workflow
engine.
--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
"chetan rane" <[email protected]> wrote in message
news:[email protected]...
> Hi Ben
>
> The quickest way to this is by using a framework.
> and the best way i could find was using the yiiframework
> www.yiiframework.com
>
> i could create a basic form with validations in less then 15 minutes.
>
> On Wed, Oct 28, 2009 at 6:42 AM, [email protected] <[email protected]>
> wrote:
>
>> Does anyone have a quick way of converting tables into forms?
>>
>> --
>> **********************************************************************
>> The content of this e-mail message and any attachments are
>> confidential and may be legally privileged, intended solely for the
>> addressee. If you are not the intended recipient, be advised that any
>> use, dissemination, distribution, or copying of this e-mail is
>> strictly prohibited. If you receive this message in error, please
>> notify the sender immediately by reply email and destroy the message
>> and its attachments.
>> *********************************************************************
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> with regards,
>
> Chetan Dattaram Rane
> Mob : +91 9766646714
> Phone: 0831-2462055
>
--- End Message ---
--- Begin Message ---
On Tue, 2009-10-27 at 21:07 -0700, [email protected] wrote:
> I am trying to take MySQL tables and use the table structure to create
> HTML/PHP forms in as few steps as possible for further development. I
> have a project that has hundreds of tables and requires hundreds of
> forms to be created and don't want to do so field by field by hand.
>
> Thanks,
>
> Ben
>
> On Tuesday, October 27, 2009, Allen McCabe <[email protected]> wrote:
> > Please explain with much greater detail.
> >
> > On Tue, Oct 27, 2009 at 6:12 PM, [email protected] <[email protected]> wrote:
> > Does anyone have a quick way of converting tables into forms?
> >
> > --
> > **********************************************************************
> > The content of this e-mail message and any attachments are
> > confidential and may be legally privileged, intended solely for the
> > addressee. If you are not the intended recipient, be advised that any
> > use, dissemination, distribution, or copying of this e-mail is
> > strictly prohibited. If you receive this message in error, please
> > notify the sender immediately by reply email and destroy the message
> > and its attachments.
> > *********************************************************************
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
>
> --
> **********************************************************************
> The content of this e-mail message and any attachments are
> confidential and may be legally privileged, intended solely for the
> addressee. If you are not the intended recipient, be advised that any
> use, dissemination, distribution, or copying of this e-mail is
> strictly prohibited. If you receive this message in error, please
> notify the sender immediately by reply email and destroy the message
> and its attachments.
> *********************************************************************
>
There is still the issue of exactly what db fields will translate into.
Where is a good time to use radio buttons instead of select lists, or
checkboxes instead of select-multiple lists? What about text fields in
the db? Should they be textareas or text inputs? Do all the db fields
need to be translated as visible fields? Should you hide ID fields?
There are so many questions, that you might be better off rolling your
own, as a one-size-fits-all will not always work for everyone.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
[email protected] wrote:
> I am trying to take MySQL tables and use the table structure to create
> HTML/PHP forms in as few steps as possible for further development. I
> have a project that has hundreds of tables and requires hundreds of
> forms to be created and don't want to do so field by field by hand.
>
> Thanks,
>
> Ben
>
> On Tuesday, October 27, 2009, Allen McCabe <[email protected]> wrote:
>> Please explain with much greater detail.
>>
>> On Tue, Oct 27, 2009 at 6:12 PM, [email protected] <[email protected]> wrote:
>> Does anyone have a quick way of converting tables into forms?
Use the CakePHP framework. Run a script, type in your database info and
it will scan all your tables and generate the forms and the list,
update, delete code for each table. It should be fully functional then
and you can tweak to your needs to add table relations etc.
--
Thanks!
-Shawn
http://www.spidean.com
--- End Message ---
--- Begin Message ---
From: Ashley Sheridan
> On Tue, 2009-10-27 at 21:07 -0700, [email protected] wrote:
>
>> I am trying to take MySQL tables and use the table structure to
create
>> HTML/PHP forms in as few steps as possible for further development. I
>> have a project that has hundreds of tables and requires hundreds of
>> forms to be created and don't want to do so field by field by hand.
>>
>> On Tuesday, October 27, 2009, Allen McCabe <[email protected]>
wrote:
>> > Please explain with much greater detail.
>> >
>> > On Tue, Oct 27, 2009 at 6:12 PM, [email protected]
<[email protected]> wrote:
>> > Does anyone have a quick way of converting tables into forms?
>> >
>
> There is still the issue of exactly what db fields will translate
into.
> Where is a good time to use radio buttons instead of select lists, or
> checkboxes instead of select-multiple lists? What about text fields in
> the db? Should they be textareas or text inputs? Do all the db fields
> need to be translated as visible fields? Should you hide ID fields?
>
> There are so many questions, that you might be better off rolling your
> own, as a one-size-fits-all will not always work for everyone.
I have a feeling in the pit of my stomach that your project is going to
create a support nightmare. Either you will have to hand code forms for
each table, or find a framework that dynamically creates the forms from
schema and create suitable maps for each form. In either case, it will
take weeks or months to complete and be nearly impossible to maintain
when tables are changed or added.
If your solution requires you to create hundreds of forms, which could
take months to code, you need to take another look at the problem. I
don't believe you have thought it through very well.
Bob McConnell
--- End Message ---
--- Begin Message ---
On Wed, Oct 28, 2009 at 8:53 AM, Bob McConnell <[email protected]> wrote:
> From: Ashley Sheridan
>
>> On Tue, 2009-10-27 at 21:07 -0700, [email protected] wrote:
>>
>>> I am trying to take MySQL tables and use the table structure to
> create
>>> HTML/PHP forms in as few steps as possible for further development. I
>>> have a project that has hundreds of tables and requires hundreds of
>>> forms to be created and don't want to do so field by field by hand.
>>>
>>> On Tuesday, October 27, 2009, Allen McCabe <[email protected]>
> wrote:
>>> > Please explain with much greater detail.
>>> >
>>> > On Tue, Oct 27, 2009 at 6:12 PM, [email protected]
> <[email protected]> wrote:
>>> > Does anyone have a quick way of converting tables into forms?
>>> >
>>
>> There is still the issue of exactly what db fields will translate
> into.
>> Where is a good time to use radio buttons instead of select lists, or
>> checkboxes instead of select-multiple lists? What about text fields in
>> the db? Should they be textareas or text inputs? Do all the db fields
>> need to be translated as visible fields? Should you hide ID fields?
>>
>> There are so many questions, that you might be better off rolling your
>> own, as a one-size-fits-all will not always work for everyone.
>
> I have a feeling in the pit of my stomach that your project is going to
> create a support nightmare. Either you will have to hand code forms for
> each table, or find a framework that dynamically creates the forms from
> schema and create suitable maps for each form. In either case, it will
> take weeks or months to complete and be nearly impossible to maintain
> when tables are changed or added.
>
> If your solution requires you to create hundreds of forms, which could
> take months to code, you need to take another look at the problem. I
> don't believe you have thought it through very well.
>
> Bob McConnell
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
symfony might be another option, but it will take you some time to
sort out the yaml config.
--
Bastien
Cat, the other other white meat
--- End Message ---
--- Begin Message ---
[snip]If your solution requires you to create hundreds of forms, which
could
take months to code, you need to take another look at the problem. I
don't believe you have thought it through very well.[/snip]
Actually you could use the function I provided to do this on the fly or
have the function write out a file for each table involved.
--- End Message ---
--- Begin Message ---
tedd schreef:
Hi gang:
I just had a script stop following this statement:
header("Location:users.php");
It *was* working, but now instead of running "users.php", it defaults to
the parent script.
When I place exit() after it, such as:
header("Location:users.php");
exit();
The script simply exits. It does not continue to users.php -- BUT -- it
did.
What would stop this statement from working?
Thanks,
tedd
If ANYTHING is output before header(), it stops working. Did you turn
off error reporting? You might want to double-check, because it returns
an error if anything is output.
--
Kind regards,
Mark Cilissen / Pixlism
--- End Message ---
--- Begin Message ---
tedd schreef:
Hi gang:
I just had a script stop following this statement:
header("Location:users.php");
It *was* working, but now instead of running "users.php", it defaults to
the parent script.
When I place exit() after it, such as:
header("Location:users.php");
exit();
The script simply exits. It does not continue to users.php -- BUT -- it
did.
What would stop this statement from working?
Thanks,
tedd
If ANYTHING is output before header(), it stops working. Did you turn
off error reporting? You might want to double-check, because it returns
an error if anything is output.
--
Kind regards,
Mark Cilissen / Pixlism
--- End Message ---
--- Begin Message ---
2009/10/28 Raymond Irving <[email protected]>:
> I'm try to do something like what Martin Scotta did but I'm looking for a
> solution that did not require me to loop through get_declared classes() to
> find a sub class.
Place all your child classes in the same namespace, and use
ReflectionNamespace::getClasses().
But I stress, again, that I think there's a design issue that needs to
be fixed here. There's going to be a better way to do what you're
trying to do.
--- End Message ---
--- Begin Message ---
2009/10/28 David Otton <[email protected]>:
> 2009/10/28 Raymond Irving <[email protected]>:
>
>> I'm try to do something like what Martin Scotta did but I'm looking for a
>> solution that did not require me to loop through get_declared classes() to
>> find a sub class.
>
> Place all your child classes in the same namespace, and use
> ReflectionNamespace::getClasses().
Hah. Turns out that's on the @todo list... wait for PHP 5.4 maybe.
--- End Message ---
--- Begin Message ---
From: Skip Evans
> I just downloaded the Netbeans 6.5 IDE to use as a code
> editor, installed the PHP plugin for syntax highlighting and
> it didn't look so good, so I find on the forum a guy who has
> made a collection of files, starting in a directory called
> config, that will apparently change the highlighting more in
> line to what I'm used to.
>
> But he gave no instructions how this is to be installed and I
> can't find anywhere in the documentation how to install this
> stuff.
Three questions.
1. Why did you install an obsolete version? 6.7.1 is current and 6.8 is
now in beta.
2. You just asked this question on the NetBeans mailing list, which is
more likely to result in a useable answer. Can't you wait for them?
3. Did you try reading the help section on "Configuring IDE Settings"?
Once again you forgot to include that you installed this on Ubuntu.
Bob McConnell
--- End Message ---
--- Begin Message ---
If you go Tools>Options> Keymap tab, you can click the 'Import' button at
the bottom. It just imports the zip file.
I'm new to Netbeans myself and decided to install this colour scheme,
however I can't get it to display correctly.
I'm also missing word wrap and a more simple one-click FTP upload interface,
so I'm still in half a mind as to whether I abandon NuSphere (which we sort
of grew up with) just yet.
Unless anyone out there knows any plugins that add the functionality to
Netbeans?
-----Original Message-----
From: Skip Evans [mailto:[email protected]]
Sent: 28 October 2009 00:50
To: [email protected]
Subject: Netbeans IDE 6.5
Hey all,
I just downloaded the Netbeans 6.5 IDE to use as a code
editor, installed the PHP plugin for syntax highlighting and
it didn't look so good, so I find on the forum a guy who has
made a collection of files, starting in a directory called
config, that will apparently change the highlighting more in
line to what I'm used to.
But he gave no instructions how this is to be installed and I
can't find anywhere in the documentation how to install this
stuff.
Any Netbeaners out there know how to install syntax
highlighting stuff?
I found it here.
http://forums.netbeans.org/post-46850.html
Downloaded and unzipped the archive and then I stopped like
the robot on Lost in Space when they pulled out his power pack.
Any help would be great!
Thanks,
Skip
--
====================================
Skip Evans
PenguinSites.com, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://penguinsites.com
------------------------------------
Those of you who believe in
telekinesis, raise my hand.
-- Kurt Vonnegut
--- End Message ---
--- Begin Message ---
[snip]
Anyone know of a way to can take Mysql tables/fields from phpMyAdmin or
.sql
file and quickly make into HTML forms?
[/snip]
Search the archive of this list. I posted a function that does this a
long while back.
--- End Message ---
--- Begin Message ---
[snip]
Anyone know of a way to can take Mysql tables/fields from phpMyAdmin or
.sql file and quickly make into HTML forms?
[/snip]
Here is that function...(there are many mods that can be made to this,
but it works)
/*
* SQL Extactor
* Author: jblanchard
*
* Business Rule: <if applicable>
*
* REVISION: Jun 19, 2006
* USAGE: used to create form based on sql database info.
* dis be da ugly version, needs to be funkionized
*
*/
/* database connection */
if(!$dc = mysql_connect('yourdatabase', 'username', 'password')){
echo mysql_error();
exit();
}
function formCreate($database, $table, $action, $excludeCols,
$recordID){
/*
* This function is used to create forms on the fly based on
tables within
* the database. The minimal arguments are database name and
table name.
* Additional arguements may be supplied to indicate columns to
be excluded
* from form and an action (CRUD) to be performed once the form
* is filled out. If wanting to do an update, read or delete you
can specify
* a record to retrieve to populate the form. Default values
will be provided
* for arguements not included.
*/
/* database connection in global variable */
global $dc;
/* number of arguements sent to function */
$numArgs = func_num_args();
/* test to make sure that you have the minial two arguements */
if(2 > $numArgs){
/* not enough arguments */
$errMsg = "not enough arguements supplied, please supply
database and table name";
return($errMsg);
} else {
/*
* Supply default values for optional arguements if they
are not set.
* An interesting note here: the action can be anything
that the user
* specifies, it is not strictly limited to CRUD and it
will be output
* in a hidden form field;
* <input type="hidden" name="action" value="whatever
action is called">
* That way when the user clicks 'Submit' the programmer
can have a
* switch action in his or her processing script to
handle this form.
*/
if(!isset($action)) { $action = 'read'; }
if(!isset($recordID)) { $recordID = ''; }
if(!isset($excludeCols)){
$excludeCols = '';
} else {
/* create an array of excluded columns */
$arrExcludeCols = explode(",", $excludeCols);
}
/* describe the table */
$sqlDesc = "DESCRIBE `".$database."`.`".$table."` ";
if(!($dbInfo = mysql_query($sqlDesc, $dc))){
return mysql_error();
} else {
while($tableInfo = mysql_fetch_array($dbInfo)){
/*
* regular expression - we need the data
that exists between the
* parentheses in the Type column of the
database being described
* so that we can use for length values
of form fields
*/
if(!(in_array($tableInfo['Field'],
$arrExcludeCols))){
if(preg_match (
"/\((\d{1,}.*?)\)/", $tableInfo[1], $regs )){
/* handle numerical
values in parentheses to create form element lengths */
echo
"<label>".$tableInfo['Field']."</label>";
echo "<input
type=\"text\" name=\"".$tableInfo['Field']."\" size=\"".$regs[1]."\"
maxlength=\"".$regs[1]."\"><br />\n";
} elseif("text" ==
$tableInfo[1]) {
/* handle text columns
*/
echo
"<label>".$tableInfo['Field']."</label>";
echo "<textarea
name=\"".$tableInfo['Field']."\" cols=\"80\" rows=\"10\"></textarea><br
/>\n";
} elseif("enum" ==
substr($tableInfo[1], 0, 4)){
/* handle enumerated
columns and creat drop downs */
echo
"<label>".$tableInfo['Field']."</label> ";
/*
* regular expression -
we need the data that
* exists between the
single quotes in the Type column of the
* database being
described so that we can use for option
* values in a drop-down
on the form
*/
preg_match_all(
"/'(.*)'/U", $tableInfo[1], $matches);
echo "<select
name=\"".$tableInfo['Field']."\">\n";
echo
"<option></option>\n";
for($i = 0; $i <
count($matches[1]); $i++){
echo
"<option>".$matches[1][$i]."</option>\n";
}
echo "</select><br
/>\n";
}//end if preg
}//end if in_array
}//end while tableInfo
/* set up the hidden action field */
echo "<input type=\"hidden\" name=\"action\"
value=\"".$action."\">\n";
/* provide a submit and reset button */
echo "<input type=\"submit\" name=\"submit\"
value=\"Submit\"> ";
echo "<input type=\"reset\" name=\"reset\"
value=\"Clear\"><br />\n";
return;
}// end if dbInfo
}// end if numArgs
}//end function formCreate
--- End Message ---
--- Begin Message ---
Hello all,
Please have a look here:
http://www.nuvemk.com/c_categoria/seccao/1
When we click on "Fitofármacos", I can display the correspondent children!
This is great! And I'm really happy!
:)
When we click on Fitofármacos children - "Herbicidas", I was expecting to
have returned Herbicidas childs, without losing the Fitofármacos menu item.
The reason I'm losing him, I suppose, it's due the fact that the URI is not
properly generated by the function responsible to parse a menu.
Notice that, on the link posted above:
If you click on fitofármacos and then click on herbicidas, the expected URL
should be:
http://www.nuvemk.com/c_categoria/seccao/1/6/9/
but I'm getting this instead:
http://www.nuvemk.com/c_categoria/seccao/6/9/
If we try to navigate deeply, and inside Herbicidas we click on "Herbicidas
A", we are expecting an URL like so:
http://www.nuvemk.com/c_categoria/seccao/1/6/9/27/
But we are getting this instead:
http://www.nuvemk.com/c_categoria/seccao/9/27/
Here is the actual code:
http://pastebin.com/m8ffe9db
I've not yet completely understand the recursion, can I have your help in
order to understand how can I recursively build the URI segments?
Thanks a lot in advance,
Márcio
--- End Message ---
--- Begin Message ---
Hi,
I was just wondering what the difference/advantage of these two
methods of writing a string are:
1) $string = "foo{$bar}";
2) $string = 'foo'.$bar;
I always use method 2 but have been noticing method 1 more and more in
source code. Is this just user preference?
I would use a generic search engine but not sure what the first method
is called so don't know where to begin my search.
Thanks for any help.
Nick
--- End Message ---
--- Begin Message ---
[snip]I was just wondering what the difference/advantage of these two
methods of writing a string are:[/snip]
Method 2 is faster, YMMV.
--- End Message ---
--- Begin Message ---
Nick Cooper wrote:
> Hi,
>
> I was just wondering what the difference/advantage of these two
> methods of writing a string are:
>
> 1) $string = "foo{$bar}";
>
> 2) $string = 'foo'.$bar;
>
> I always use method 2 but have been noticing method 1 more and more in
> source code. Is this just user preference?
>
> I would use a generic search engine but not sure what the first method
> is called so don't know where to begin my search.
>
> Thanks for any help.
>
> Nick
>
I think it is a matter of personal preference. I prefer method 1 myself.
--- End Message ---