You are here: Re: wandering in dis- array « PHP SQL « IT news, forums, messages
Re: wandering in dis- array

Posted by strawberry on 11/06/06 16:02

strawberry wrote:
> Captain Paralytic wrote:
> > strawberry wrote:
> >
> > blah, blah, blah...
> >
> > Sniped all the stuff, 'cos it was getting too big!
> >
> > I can see what is wrong, but I'm not sure exactly what you want to
> > achieve.
> >
> > The reason for getting the first INSERT that has a field called "name"
> > is that the original code will output an INSERT statement for every
> > array element that is processed, since the echo is outside of the "if"
> > statement that identifies a table "name" field.
> >
> > Now in your first example you said that the required output was for
> > every INSERT to have a single key/value pair. In the most recent one
> > you are suggesting that they are collected together.
> >
> > In either case you need to ensure that the first element of the array
> > is a "name" element.
> >
> > Also, your statement about keeping the table name till you encounter
> > another "name" element would not happen, as any array can only have one
> > element with a particular value of "key". In your processing you are
> > calling the function recursively whenever you encounter a "sub-array",
> > so that all the variables will start off empty as you are not using any
> > "static" variables.
> >
> > If your sub-arrays are supposed to have the same table value as was
> > previously encountered, then you need to make the $table variable
> > accessable to the new instance of the function call.
> >
> > Take a look at http://uk.php.net/static for pointers on what I think
> > you need to do.
> >
> > There isn't quite enough of the var_export shown fo me to be 100% sure
> > that this'll fix it, but I am 95%.
> >
> > HTH
> > Regards
> > Paul
>
> Thanks a lot for the pointer CP. I'll take a look at it right away.

Yep, excellent. That seems to have sorted out that problem.

function array_to_mysql($array) //define the function
{
static $table = null;

etc, etc...

1 down, maybe 9 to go?

Anyway, thanks again.

 

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

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