php-general Digest 24 Oct 2008 14:20:45 -0000 Issue 5753

Topics (messages 282380 through 282400):

Re: export data to a ms excel file using php
        282380 by: Ashley Sheridan

Re: Method of connecting image
        282381 by: Ashley Sheridan
        282388 by: Bastien Koert

Re: Politics
        282382 by: Colin Guthrie
        282390 by: Bastien Koert

Re: web shot script
        282383 by: Joey
        282385 by: Andrew Barnett
        282386 by: Afan Pasalic
        282389 by: Andrew Barnett
        282391 by: Afan Pasalic
        282392 by: Andrew Barnett
        282393 by: Paul Scott
        282397 by: Richard Heyes

index search
        282384 by: Ryan S
        282387 by: Robert Cummings
        282400 by: Andrew Ballard

PHP/mySQL question using ORDER BY with logic
        282394 by: Rob Gould
        282395 by: Robert Cummings
        282398 by: Colin Guthrie

Re: ZendOptimizer + APC
        282396 by: steve

Re: what's the difference in the following code?
        282399 by: Yeti

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 ---
On Thu, 2008-10-23 at 13:05 +0530, gopi krishnan wrote:
> Hi,
> 
> Could any one explain better. I need just the grid lines for the excel
> sheet. I already tried that <table border=1> but it shows the linings only
> to the valued cells. But i need to show the grid as in MS Excel. I tried
> TEXT/XML
> but i get the following error
> 
> ---------------------------
> 
> The XML page cannot be displayed
> 
> Cannot view XML input using XSL style sheet. Please correct the error and
> then click the Refresh <javascript:location.reload()> button, or try again
> later.
> ------------------------------
> 
> A string literal was expected, but no opening quote character was found.
> Error processing resource 'http://localhost/dbtoxl...
> 
> <table border="1"><tr> <td width=100>25 </td><td width=100> jana
> </td><td  width=100&...
> 
> 
> ---------------------------
> 
> thanks in advance....
> 
> 
> On Thu, Oct 23, 2008 at 3:21 AM, Nitsan Bin-Nun <[EMAIL PROTECTED]> wrote:
> 
> > And what about users who use office version < 2003 (which do NOT support
> > .xml charts)
> > You can google a bit, I'm pretty sure I have already encountered a class
> > for this case at Manuel's site (phpclasses).
> >
> > Nitsan
> >
> > On Wed, Oct 22, 2008 at 9:00 PM, Ashley Sheridan <[EMAIL PROTECTED]
> > > wrote:
> >
> >> On Wed, 2008-10-22 at 11:20 -0700, Jim Lucas wrote:
> >> > [EMAIL PROTECTED] wrote:
> >> > > Hi,
> >> > >
> >> > > I have tried your MS-Excel MIME type in PHP. But am facing a small
> >> problem. I can't get the grid lines as look like in normal Excel file.
> >> > >
> >> > > Am using windows XP, Internet explorer 6.0, MS Excel 2003
> >> > >
> >> > > Thanks in advance.-- Jim Lucas wrote :
> >> > > abderrazzak nejeoui wrote:
> >> > >> can you help me to export data to a ms excel file using php. i tried
> >> to
> >> > >> export them to an html format and change the extension to .xls that's
> >> work
> >> > >> but i have lost the formatting
> >> > >>
> >> > >> excel and the navigator doesn't interpret my code in the same why
> >> (celles
> >> > >> are not in the same size)
> >> > >>
> >> > >
> >> > > Ok, so with the examples of others here, here is the shortest example
> >> that I came up with that
> >> > > should get you going.
> >> > >
> >> > > <?php
> >> > >
> >> > > header("Content-Type:  application/vnd.ms-excel");
> >> > > header("Expires: 0");
> >> > > header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
> >> > >
> >> > > $x = $y = range(0, 12);
> >> > >
> >> > > echo '<table>';
> >> > >
> >> > > echo '<tr><td> </td><td>' . join('</td><td>', $x) . '</td></tr>';
> >> > >
> >> > > foreach ( $x AS $xx ) {
> >> > >     echo "<tr><td>{$xx}</td>";
> >> > >     foreach ( $y AS $yy ) {
> >> > >             echo
> >> "<td>=sum(".(chr(ord('b')+$yy))."1*a".($xx+2).")</td>";
> >> > >     }
> >> > >     echo "</tr>";
> >> > > }
> >> > > echo '</table>';
> >> > >
> >> > > ?>
> >> > >
> >> > > This will output a 14x14 table.  It will calculate the totals for each
> >> cell in the actual
> >> > > spreadsheet once excel loads it.
> >> > >
> >> > > If you have any questions, ask away.
> >> > >
> >> >
> >> > You could change this line
> >> >
> >> > echo '<table>';
> >> >
> >> > to this
> >> >
> >> > echo '<table border="1">';
> >> >
> >> > This will give you borders around your content at least.
> >> >
> >> > Example:
> >> >
> >> http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php
> >> >
> >> > I would checkout phpexcel also
> >> >
> >> > --
> >> > Jim Lucas
> >> >
> >> >    "Some men are born to greatness, some achieve greatness,
> >> >        and some have greatness thrust upon them."
> >> >
> >> > Twelfth Night, Act II, Scene V
> >> >     by William Shakespeare
> >> >
> >> >
> >> I think you really need to save the file as an XML file, with the
> >> text/xml mime-type. Then, save an Excel file in the M$ Office 2003 XML
> >> file-type (not the 2007 xlsx!) and look at the code it produces and try
> >> to mimic that output as closely as possible. All you're doing is
> >> creating an HTML table and hoping Excel knows what to do with it, which
> >> is a bit like creating an image, sending it to the browser with a PDF
> >> mime and hoping it will open up in Adobe Reader; just not gonna work
> >> that way!
> >>
> >> Your best bet by far though, is to use a pre-built Excel export class.
> >> Take a look at PEAR of PHPLib, as these both have classes that do what
> >> you need.
> >>
> >>
> >> Ash
> >> www.ashleysheridan.co.uk
> >>
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
the problem here is that you don't seem to understand the difference
between xml, html and the binary excel format. Pick one, find out how it
works and go with it. You seem to think that if you send down html to a
browser, but give it a mime-type of application/excel it will suddenly
become an excel document. not gonna happen, ever, period.

my suggestion about using the text/xml header will only work _if you
write the file as xml_ which you aren't. try using a class, or pay
someone to do it if you can't.


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
On Thu, 2008-10-23 at 23:44 +0900, [EMAIL PROTECTED] wrote:
> Hi
> 
> Is there a method of connecting the jpg image with PHP?
> For instance, four images tie by two in two length in side. 
> 
> 
> Napura
> ************************************
> Linux Debian4 (Server)
> PHP 5.2.2
> Apache 2.2.4
> MySQL
> 
Sorry, what is the question again? I'm afraid I don't understand what it
is you're looking for.


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
On Thu, Oct 23, 2008 at 7:11 PM, Ashley Sheridan
<[EMAIL PROTECTED]>wrote:

> On Thu, 2008-10-23 at 23:44 +0900, [EMAIL PROTECTED] wrote:
> > Hi
> >
> > Is there a method of connecting the jpg image with PHP?
> > For instance, four images tie by two in two length in side.
> >
> >
> > Napura
> > ************************************
> > Linux Debian4 (Server)
> > PHP 5.2.2
> > Apache 2.2.4
> > MySQL
> >
> Sorry, what is the question again? I'm afraid I don't understand what it
> is you're looking for.
>
>
> Ash
> www.ashleysheridan.co.uk
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>  Google 'php image stitcher' and go thru the results. There are lots of
entries, some good some bad...


-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
Daniel P. Brown wrote:
 Mandriva Linux Contributor [http://www.mandriva.com/]

    Hooray for Cooker!

:D

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


--- End Message ---
--- Begin Message ---
On Thu, Oct 23, 2008 at 6:05 PM, Amy <[EMAIL PROTECTED]> wrote:

>
> mouso prefixes egging gestures loozr selected incomprehensibly assumed
> sexism
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Time to remove her from the list.

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
Hi Guys,

Really I want to do this, not pay someone to do it via those services you
linked to.
So nobody has seen open source code for this?


> -----Original Message-----
> From: Joey [mailto:[EMAIL PROTECTED]
> Sent: Saturday, October 18, 2008 4:59 AM
> To: PHP
> Subject: [PHP] web shot script
> 
> Hello All,
> 
> 
> Does anyone know of a script to capture web pages and store the image?
> 
> Trying to see all of my sites screenshots and have it updated on occasion.
> 
> 
> 
> Thanks!
> 
> 
> 
> Joey



--- End Message ---
--- Begin Message ---
Hey Joey,
I had a search, and from what I found, it would be very difficult unless you
have root access to a server. Another way would be to create a HTML/CSS
renderer using PHP, and then using that to take a screenshot.

A link from DigitalPoint <
http://forums.digitalpoint.com/showthread.php?t=76454> may provide some
clues, or discouragement as I found.

Let us know if you work out how to do it. I'd love to know.


Andrew

2008/10/24 Joey <[EMAIL PROTECTED]>

> Hi Guys,
>
> Really I want to do this, not pay someone to do it via those services you
> linked to.
> So nobody has seen open source code for this?
>
>
> > -----Original Message-----
> > From: Joey [mailto:[EMAIL PROTECTED]
> > Sent: Saturday, October 18, 2008 4:59 AM
> > To: PHP
> > Subject: [PHP] web shot script
> >
> > Hello All,
> >
> >
> > Does anyone know of a script to capture web pages and store the image?
> >
> > Trying to see all of my sites screenshots and have it updated on
> occasion.
> >
> >
> >
> > Thanks!
> >
> >
> >
> > Joey
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---

Andrew Barnett wrote:
Hey Joey,
I had a search, and from what I found, it would be very difficult unless you
have root access to a server. Another way would be to create a HTML/CSS
renderer using PHP, and then using that to take a screenshot.

or, maybe, as an idea, save the page as pdf?


A link from DigitalPoint <
http://forums.digitalpoint.com/showthread.php?t=76454> may provide some
clues, or discouragement as I found.

Let us know if you work out how to do it. I'd love to know.


Andrew

2008/10/24 Joey <[EMAIL PROTECTED]>

Hi Guys,

Really I want to do this, not pay someone to do it via those services you
linked to.
So nobody has seen open source code for this?


-----Original Message-----
From: Joey [mailto:[EMAIL PROTECTED]
Sent: Saturday, October 18, 2008 4:59 AM
To: PHP
Subject: [PHP] web shot script

Hello All,


Does anyone know of a script to capture web pages and store the image?

Trying to see all of my sites screenshots and have it updated on
occasion.

Thanks!



Joey

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--- End Message ---
--- Begin Message ---
Are you suggesting to create a PDF, and then convert from PDF to an image?

Andrew



2008/10/24 Afan Pasalic <[EMAIL PROTECTED]>

>
> Andrew Barnett wrote:
>
>> Hey Joey,
>> I had a search, and from what I found, it would be very difficult unless
>> you
>> have root access to a server. Another way would be to create a HTML/CSS
>> renderer using PHP, and then using that to take a screenshot.
>>
>>
>>
> or, maybe, as an idea, save the page as pdf?
>
>
>  A link from DigitalPoint <
>> http://forums.digitalpoint.com/showthread.php?t=76454> may provide some
>> clues, or discouragement as I found.
>>
>> Let us know if you work out how to do it. I'd love to know.
>>
>>
>> Andrew
>>
>> 2008/10/24 Joey <[EMAIL PROTECTED]>
>>
>>
>>
>>> Hi Guys,
>>>
>>> Really I want to do this, not pay someone to do it via those services you
>>> linked to.
>>> So nobody has seen open source code for this?
>>>
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: Joey [mailto:[EMAIL PROTECTED]
>>>> Sent: Saturday, October 18, 2008 4:59 AM
>>>> To: PHP
>>>> Subject: [PHP] web shot script
>>>>
>>>> Hello All,
>>>>
>>>>
>>>> Does anyone know of a script to capture web pages and store the image?
>>>>
>>>> Trying to see all of my sites screenshots and have it updated on
>>>>
>>>>
>>> occasion.
>>>
>>>
>>>>
>>>> Thanks!
>>>>
>>>>
>>>>
>>>> Joey
>>>>
>>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>>>
>>
>>
>>
>

--- End Message ---
--- Begin Message ---

Andrew Barnett wrote:
Are you suggesting to create a PDF, and then convert from PDF to an image?
I'm sorry. didn't get it has to be an image.



Andrew



2008/10/24 Afan Pasalic <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>


    Andrew Barnett wrote:

        Hey Joey,
        I had a search, and from what I found, it would be very
        difficult unless you
        have root access to a server. Another way would be to create a
        HTML/CSS
        renderer using PHP, and then using that to take a screenshot.

    or, maybe, as an idea, save the page as pdf?


        A link from DigitalPoint <
        http://forums.digitalpoint.com/showthread.php?t=76454> may
        provide some
        clues, or discouragement as I found.

        Let us know if you work out how to do it. I'd love to know.


        Andrew

        2008/10/24 Joey <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>

            Hi Guys,

            Really I want to do this, not pay someone to do it via
            those services you
            linked to.
            So nobody has seen open source code for this?


                -----Original Message-----
                From: Joey [mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>]
                Sent: Saturday, October 18, 2008 4:59 AM
                To: PHP
                Subject: [PHP] web shot script

                Hello All,


                Does anyone know of a script to capture web pages and
                store the image?

                Trying to see all of my sites screenshots and have it
                updated on
            occasion.

                Thanks!



                Joey

            --
            PHP General Mailing List (http://www.php.net/)
            To unsubscribe, visit: http://www.php.net/unsub.php





--- End Message ---
--- Begin Message ---
You might actually be onto something there Afan.

As long as Ghostscript and Imagemagick are installed on the server, you will
be able to convert a PDF to an image. So maybe that will help.

Although, is it possible to have a continuous length PDF, or does it only
fit to specific page sizes.

Its probably worth a shot though Joey.


Andrew



2008/10/24 Afan Pasalic <[EMAIL PROTECTED]>

>
> Andrew Barnett wrote:
>
>> Are you suggesting to create a PDF, and then convert from PDF to an image?
>>
> I'm sorry. didn't get it has to be an image.
>
>
>
>> Andrew
>>
>>
>>
>> 2008/10/24 Afan Pasalic <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
>>
>>
>>    Andrew Barnett wrote:
>>
>>        Hey Joey,
>>        I had a search, and from what I found, it would be very
>>        difficult unless you
>>        have root access to a server. Another way would be to create a
>>        HTML/CSS
>>        renderer using PHP, and then using that to take a screenshot.
>>
>>
>>    or, maybe, as an idea, save the page as pdf?
>>
>>
>>        A link from DigitalPoint <
>>        http://forums.digitalpoint.com/showthread.php?t=76454> may
>>        provide some
>>        clues, or discouragement as I found.
>>
>>        Let us know if you work out how to do it. I'd love to know.
>>
>>
>>        Andrew
>>
>>        2008/10/24 Joey <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
>>
>>
>>            Hi Guys,
>>
>>            Really I want to do this, not pay someone to do it via
>>            those services you
>>            linked to.
>>            So nobody has seen open source code for this?
>>
>>
>>
>>                -----Original Message-----
>>                From: Joey [mailto:[EMAIL PROTECTED] <mailto:[EMAIL 
>> PROTECTED]>]
>>                Sent: Saturday, October 18, 2008 4:59 AM
>>                To: PHP
>>                Subject: [PHP] web shot script
>>
>>                Hello All,
>>
>>
>>                Does anyone know of a script to capture web pages and
>>                store the image?
>>
>>                Trying to see all of my sites screenshots and have it
>>                updated on
>>
>>            occasion.
>>
>>
>>                Thanks!
>>
>>
>>
>>                Joey
>>
>>
>>            --
>>            PHP General Mailing List (http://www.php.net/)
>>            To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>>
>>
>>
>>

--- End Message ---
--- Begin Message ---
On Thu, 2008-10-23 at 22:20 -0400, Joey wrote:

> Really I want to do this, not pay someone to do it via those services you
> linked to.
> So nobody has seen open source code for this?

I run a free (freedom and beer) webservice to do this via the Chisimba
framework (http://avoir.uwc.ac.za) The docs and files are all in svn so
if you would like em, get em! The screenshot code is in python though.

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

--- End Message ---
--- Begin Message ---
> The other options is using something like www.browsershots.org (as far
> as I remember thats their URL) and pay them to get the first places on
> their queues.

Wow, That's really a very handy tool.

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org

--- End Message ---
--- Begin Message ---
Hey all,
Was wondering how this is done, have a bunch of links like so:
0-9 : a : b : c -----> till Z

these will be linked to the program (so far have done this) but when the user 
clicks any of those links I want to query the DB for just the first alphabet 
from the field "title", using LIKE is not working for me because its catching 
alphabets from the middle of the word as well.

Also how to do 0-9? do i have to have 10 if() conditions for that?

Ideas and suggestions welcome.

Thanks!
Ryan

 ------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)



      

--- End Message ---
--- Begin Message ---
On Thu, 2008-10-23 at 19:30 -0700, Ryan S wrote:
> Hey all,
> Was wondering how this is done, have a bunch of links like so:
> 0-9 : a : b : c -----> till Z
> 
> these will be linked to the program (so far have done this) but when the user 
> clicks any of those links I want to query the DB for just the first alphabet 
> from the field "title", using LIKE is not working for me because its catching 
> alphabets from the middle of the word as well.

You're using like wrong... you want to use it with one %...

    where foo like 'a%'

> Also how to do 0-9? do i have to have 10 if() conditions for that?

Maybe you could add a new field to the table and set it to the first
character of the field or 0 if it's a digit. Then you can index it and
not use "like" or multiple conditions to match digits.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
On Thu, Oct 23, 2008 at 10:49 PM, Robert Cummings <[EMAIL PROTECTED]> wrote:
> On Thu, 2008-10-23 at 19:30 -0700, Ryan S wrote:
>> Hey all,
>> Was wondering how this is done, have a bunch of links like so:
>> 0-9 : a : b : c -----> till Z
>>
>> these will be linked to the program (so far have done this) but when the 
>> user clicks any of those links I want to query the DB for just the first 
>> alphabet from the field "title", using LIKE is not working for me because 
>> its catching alphabets from the middle of the word as well.
>
> You're using like wrong... you want to use it with one %...
>
>    where foo like 'a%'
>
>> Also how to do 0-9? do i have to have 10 if() conditions for that?
>
> Maybe you could add a new field to the table and set it to the first
> character of the field or 0 if it's a digit. Then you can index it and
> not use "like" or multiple conditions to match digits.
>
> Cheers,
> Rob.

I'm pretty sure that if your LIKE statement begins with a constant
value as you have entered above, an index on the regular columns
should still work.  :-)

As for the numeric comparison, I know MySQL has a REGEXP comparison
similar to the LIKE comparator, but I don't know enough about MySQL to
know if it can similarly benefit from indexes the same way. (SQL
Server will let you say WHERE foo LIKE '[0-9]%', but this doesn't seem
to work in MySQL.)

Andrew

--- End Message ---
--- Begin Message ---
Question about mySQL and PHP, when using the mySQL ORDER BY method...


Basically I've got data coming from the database where a "wine producer-name" is a word like:

        Château Bahans Haut-Brion

        or

        La Chapelle de La Mission Haut-Brion

        or

        Le Clarence de Haut-Brion

but I need to ORDER BY using a varient of the string:

1) If it begins with "Château", don't include "Chateau" in the string to order by. 2) If it begins with "La", don't order by "La", unless the first word is "Chateau", and then go ahead and order by "La".


Example sort: Notice how the producer as-in comes before the parenthesis, but the ORDER BY actually occurs after a re-ordering of the producer-string, using the above rules.

        Red: Château Bahans Haut-Brion (Bahans Haut-Brion, Château )
Red: La Chapelle de La Mission Haut-Brion (Chapelle de La Mission Haut-Brion, La )
        Red: Le Clarence de Haut-Brion (Clarence de Haut-Brion, Le )
        Red: Château Haut-Brion (Haut-Brion, Château )
        Red: Château La Mission Haut-Brion (La Mission Haut-Brion, Château )
Red: Domaine de La Passion Haut Brion (La Passion Haut Brion, Domaine de )
        Red: Château La Tour Haut-Brion (La Tour Haut-Brion, Château )
        Red: Château Larrivet-Haut-Brion (Larrivet-Haut-Brion, Château )
        Red: Château Les Carmes Haut-Brion (Les Carmes Haut-Brion, Château )


That logic between mySQL and PHP, I'm just not sure how to accomplish? I think it might involve a mySQL alias-technique but I could be wrong.

Right now, my PHP call to generate the search is this:

$query = 'SELECT * FROM wine WHERE MATCH(producer, varietal, appellation, designation, region, vineyard, subregion, country, vintage) AGAINST ( "' . $searchstring . '") ORDER BY producer LIMIT 0,100';


--- End Message ---
--- Begin Message ---
On Fri, 2008-10-24 at 00:18 -0400, Rob Gould wrote:
> Question about mySQL and PHP, when using the mySQL ORDER BY method...
> 
> 
>       Basically I've got data coming from the database where a "wine  
> producer-name" is a word like:
> 
>       Château Bahans Haut-Brion
> 
>       or
> 
>       La Chapelle de La Mission Haut-Brion
> 
>       or
> 
>       Le Clarence de Haut-Brion
> 
> but I need to ORDER BY using a varient of the string:
> 
>       1)  If it begins with "Château", don't include "Chateau" in the  
> string to order by.
>       2)  If it begins with "La", don't order by "La", unless the first  
> word is "Chateau", and then go ahead and order by "La".
> 
> 
>       Example sort:  Notice how the producer as-in comes before the  
> parenthesis, but the ORDER BY actually occurs after a re-ordering of  
> the producer-string, using the above rules.
> 
>       Red: Château Bahans Haut-Brion (Bahans Haut-Brion, Château )
>       Red: La Chapelle de La Mission Haut-Brion (Chapelle de La Mission  
> Haut-Brion, La )
>       Red: Le Clarence de Haut-Brion (Clarence de Haut-Brion, Le )
>       Red: Château Haut-Brion (Haut-Brion, Château )
>       Red: Château La Mission Haut-Brion (La Mission Haut-Brion, Château )
>       Red: Domaine de La Passion Haut Brion (La Passion Haut Brion,  
> Domaine de )
>       Red: Château La Tour Haut-Brion (La Tour Haut-Brion, Château )
>       Red: Château Larrivet-Haut-Brion (Larrivet-Haut-Brion, Château )
>       Red: Château Les Carmes Haut-Brion (Les Carmes Haut-Brion, Château )
> 
> 
>       That logic between mySQL and PHP, I'm just not sure how to  
> accomplish?  I think it might involve a mySQL alias-technique but I  
> could be wrong.
> 
> Right now, my PHP call to generate the search is this:
> 
> $query = 'SELECT * FROM wine WHERE MATCH(producer, varietal,  
> appellation, designation, region, vineyard, subregion, country,  
> vintage) AGAINST ( "' . $searchstring . '")  ORDER BY producer LIMIT  
> 0,100';

Maybe there's a good way to do it with the table as is... but I'm
doubtful. I would create a second field that contains a pre-processed
version of the name that performs stripping to achieve what you want.
This could be done by a PHP script when the data is inserted into the
database, or if not possible like that, then a cron job could run once
in a while, check for entries with this field empty and generate it.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
On Fri, 2008-10-24 at 00:18 -0400, Rob Gould wrote:
Question about mySQL and PHP, when using the mySQL ORDER BY method...


Basically I've got data coming from the database where a "wine producer-name" is a word like:

        Château Bahans Haut-Brion

        or

        La Chapelle de La Mission Haut-Brion

        or

        Le Clarence de Haut-Brion

but I need to ORDER BY using a varient of the string:

1) If it begins with "Château", don't include "Chateau" in the string to order by. 2) If it begins with "La", don't order by "La", unless the first word is "Chateau", and then go ahead and order by "La".


Example sort: Notice how the producer as-in comes before the parenthesis, but the ORDER BY actually occurs after a re-ordering of the producer-string, using the above rules.

        Red: Château Bahans Haut-Brion (Bahans Haut-Brion, Château )
Red: La Chapelle de La Mission Haut-Brion (Chapelle de La Mission Haut-Brion, La )
        Red: Le Clarence de Haut-Brion (Clarence de Haut-Brion, Le )
        Red: Château Haut-Brion (Haut-Brion, Château )
        Red: Château La Mission Haut-Brion (La Mission Haut-Brion, Château )
Red: Domaine de La Passion Haut Brion (La Passion Haut Brion, Domaine de )
        Red: Château La Tour Haut-Brion (La Tour Haut-Brion, Château )
        Red: Château Larrivet-Haut-Brion (Larrivet-Haut-Brion, Château )
        Red: Château Les Carmes Haut-Brion (Les Carmes Haut-Brion, Château )


That logic between mySQL and PHP, I'm just not sure how to accomplish? I think it might involve a mySQL alias-technique but I could be wrong.

Right now, my PHP call to generate the search is this:

$query = 'SELECT * FROM wine WHERE MATCH(producer, varietal, appellation, designation, region, vineyard, subregion, country, vintage) AGAINST ( "' . $searchstring . '") ORDER BY producer LIMIT 0,100';

Maybe there's a good way to do it with the table as is... but I'm
doubtful. I would create a second field that contains a pre-processed
version of the name that performs stripping to achieve what you want.
This could be done by a PHP script when the data is inserted into the
database, or if not possible like that, then a cron job could run once
in a while, check for entries with this field empty and generate it.

Yeah I'd suspect that the storage overhead is nothing compared to the speed increase you'll get during the read operations if you don't have to "dick around" with the data :)

(yes I'm comparing bits to time, but I don't have time to explain that bit).


Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


--- End Message ---
--- Begin Message ---
Run APC on the main site. Create a separate instance of apache running
on another port and have it use the ZendOptimizer, and have the admin
stuff there.

Also, have you tried changing the options for the zend thing to not
actually optimize? It only has positive effects if you are also using
their opcode cache. They moved the optimizer part into their decoder
so they could name it that for a typical bait and switch job on
unsuspecting webmasters. Bleh...


On Thu, Oct 23, 2008 at 4:44 AM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> Nathan Nobbe schreef:
>> On Wed, Oct 22, 2008 at 4:39 PM, Martin Zvarík <[EMAIL PROTECTED]> wrote:
>>
>>> Jochem Maas napsal(a):
>
> napsal(a) ... that's even weirder than my 'schreef' :-)
>
>>>> anyone know whether running ZendOptimizer + APC simultaneously still
>>>> causes allsorts
>>>> of problems ... I know it did in the past but I can't find any very recent
>>>> stuff about the
>>>> issues online.
>>>>
>>> I believe you should look up eAccelerator or XCache, which should work with
>>> ZendOptimizer.
>>
>>
>> as Jocheem said before the app is bound to apc; depends on the
>> implementation whether it could be ported to another solution.
>
> technically I can remove/replace APC - but time and desire say otherwise.
>
> the joke is that the server in question will only be running my app ... with
> the expection of a generic controlpanel thang for server management ...
> which requires ZendOptimizer ... and the sysadmin doesn't want to turn off
> ZendOptimizer because then the controlpanel app won't work
> (the server only exists to run the app/site/foo I wrote for a given client,
> but obviously I'll have to 'fix' my stuff so that the controlpanel can
> continue to run)
>
> just another wtf. regardless, thanks to those that responded.
>
>
>
>>
>> -nathan
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
>The difference between the examples are still nothing, it do the same.
>But I never use the short version of if, because when I look after some month 
>in some projects I have a better overview when there is a long if , its much 
>easier to extend.

As explained a couple of times already - there is not supposed to be a
difference.
It's about security and making code maintainance easier.

[quote to Chris's former post]
(..) imagine you're manually reviewing a colleague's code, and you're
looking through a few thousand lines to try to help identify security
problems. (..)
[end quote]

It's the old "What's good code and what's bad code?" discussion.
In this case ternary operations are bad code.

>sorry for my bad english
Die Code tun nicht Unterschiede in Execution. Es ist Sicherheits Frage.
sorry for my bad German

//A yeti

--- End Message ---

Reply via email to