Reply to Re: Optimization of mySQL to XML output...

Your name:

Reply:


Posted by Jerry Stuckle on 10/24/07 17:57

jfizer@vintara.com wrote:
> I'm trying to print out a table of mySQL data as XML. However, the
> performance I'm getting is REALY bad. Adding the header("Content-Type:
> $mime;charset=$charset"); statement triples the load time of the data
> for example. Can someone with more php experience then I look this
> over and tell me that I'm stupid and doing it wrong?
>
> define( "DATABASE_SERVER", "localhost" );
> define( "DATABASE_USERNAME", "root" );
> define( "DATABASE_PASSWORD", "" );
> define( "DATABASE_NAME", "mydatabase" );
>
> $method=$_GET['method'];
>
> //connect to the database
> $mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME,
> DATABASE_PASSWORD);
> mysql_select_db( DATABASE_NAME );
>
>
> function getDataNames()
> {
> $Query = "SELECT * from `My Data`";
> $Result = mysql_query( $Query );
> //$charset = "iso-8859-1";
> //$mime = "text/xml";
> //header("Content-Type: $mime;charset=$charset");
> print ("<response>");
> while ( $DataName = mysql_fetch_object( $Result ) )
> {
> //$Return .= "<data><name>".$DataName->DataName."</
> name><iocode>".$DataName->IOCode."</iocode><coicop>".$DataName-
>> COICOP."</coicop></data>";
> print ("<data>");
> print ("<name>".$DataName->DataName."</name>");
> print ("<code1>".$DataName->code1."</code1>");
> print ("<code2>".$DataName->code2."</code2>");
> print ("<code3>".$DataName->IOComName."</code3>");
> print ("<code4>42</code4>");
> print ("<code5>".$DataName->high_total_IOComName."</code5>");
> print ("<code6>".$DataName->high_prod_IOComName."</code6>");
> print ("<code7>".$DataName->high_whole_IOComName."</code7>");
> print ("<code8>".$DataName->high_whole_IOComName."</code8>");
> print ("<code9>".$DataName->high_whole_IOComName."</code9>");
> print ("</data>");
> }
> print ("</response>");
> mysql_free_result( $Result );
> }
>
>

Before you can optimize it, you need to find out where the hangup is.
Is it in your PHP code or MySQL?

Try inserting some calls to microtime() at strategic places in your code
and displaying out the results.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original 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

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