|
Posted by Nancy on 02/27/06 03:51
Ivan,
Thank you very much for your insight. Some very good input. I admit that I
do seriously lack understanding but am getting better.
If I had a better understanding, I could probably do without flattenArray,
but XML is returned from opening the url and I couldn't easily grasp how to
extract what I needed from the XML (not running php 5, so simple_xml is not
an option) so I used code from php.net to convert the XML into a
multi-dimensional array, but still unable to grasp how to extract what I
needed from a multi-dimensional array, I flatten into something I do
understand how to deal with.
Thanks again for your time!
nan
"Ivαn Sαnchez Ortega" <i.punto.sanchez--@rroba--mirame.punto.net> wrote in
message news:s0u9d3-up.ln1@blackspark.escomposlinux.org...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Nancy wrote:
>
>> First, I apologize if my posting format is improper.
>
> That chunk of code makes my head spin. But apart from that, it's fine.
>
>> Any efficiency pointers and stupid mistake notices are also welcome.
>
> I cannot go through all that code, but I'll drop some suggestions:
>
> - - Use variable expansion in your strings. It makes the code more
> legible.
> e.g.:
> <?php
> db_query("select * from table where data_store_no = $store_no");
> ?>
>
>
> - - Your db_query function may use global variables to store the DB
> connection, and the query result. If this is the case, avoid nesting
> db_query calls under any cost!! You might as well store all data from the
> first query in an array, then loop through that array with foreach(), and
> make sub-queries inside that loop.
> e.g., the following doesn't work:
> <?php
> $r = mysql_query("select * from user where company_id = $company_id");
> while($row = mysql_fetch_row($r))
> {
> $user_id =$row['id'];
> // The following will overwrite the value of $r and mess with the
> previous
> while loop:
> $r = mysql_query("select * from orders where user_id = $user_id");
> // (Do whatever with the data from the last query)
> }
> ?>
> Your code may be doing something like that behind the scenes.
>
>
> - - Simplify and *understand* your code. If you don't know what does this
> piece of code do, or why this bit is here, you're on the wrong track.
> Declare functions and user docbook-style comments to know what the
> different chunks of code do. The code you posted looks a bit like
> gibberish.
>
>
> - - KISS. Keep simple things simple. Do you have any real reasons to use
> flattenArray or variable variables ($$data_count_values['data_select']) ??
>
>
> - --
> - ----------------------------------
> Ivαn Sαnchez Ortega -i-punto-sanchez--arroba-mirame-punto-net
>
> "Mostly harmless."
> -- The Hitchhiker's Guide to the Galaxy.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2 (GNU/Linux)
>
> iD8DBQFEAkiv3jcQ2mg3Pc8RAv+bAJ9SmXFKapHNG/2mDLLS1MwjNu8K4ACghkVy
> maI90arkXyInTPpaHZFpcPs=
> =VZ/z
> -----END PGP SIGNATURE-----
Navigation:
[Reply to this message]
|