php-general Digest 27 Oct 2011 20:08:56 -0000 Issue 7540

Topics (messages 315446 through 315455):

Re: Exporting large data from mysql to html using php
        315446 by: David Robley
        315452 by: Tommy Pham
        315455 by: Nathan Nobbe

Re: Convert Hours to Decimal
        315447 by: Richard Quadling

Re: Friday Distraction
        315448 by: Richard Quadling

array_unique by id multi-dimensional array
        315449 by: Tontonq Tontonq
        315450 by: Jim Giner

What is wrong with this preg_match?
        315451 by: Paul Halliday
        315453 by: Steve Staples
        315454 by: Robert Williams

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Jim Giner wrote:

> "David Robley" <robl...@aapt.net.au> wrote in message
> news:49.50.34068.1b567...@pb1.pair.com...
>>
>> Consider running EXPLAIN on all your queries to see if there is something
>> Mysql thinks could be done to improve performance.
>>
> 
> Why do so many responders seem to think the problem here is in the
> preparation of the query?
> 
> It is the Approach that it is the problem.  It needs to re-addressed, not
> simply tinkered with.  I don't care if someone figures out how to spew out
> 89M+ records in 5 seconds flat.  What are you doing pulling up that many
> detail records at one time for? Who is going to look at them?  You?  If
> so, see my previous post on how long that is going to take you just to
> examine (!) the first million alone.
> 
> This problem needs a re-working of the data processing and user interfaces
> to allow for the selection of an appropriate amount of individual records
> in any result set, otherwise simply preparing a summary of some sort.

Jason originally said that he was using LIMIT to grab a subset of the data,
so I don't see why you would think he is trying to pull the full data set
in one hit. My response suggesting EXPLAIN was made in the knowledge that
he is using LIMIT.


Cheers
-- 
David Robley

"I was the first to climb Mount Everest," said Tom hilariously.
Today is Setting Orange, the 8th day of The Aftermath in the YOLD 3177. 


--- End Message ---
--- Begin Message ---
On Wed, Oct 26, 2011 at 5:47 PM, Jason Pruim <li...@pruimphotography.com>wrote:

>
> Jason Pruim
> li...@pruimphotography.com
>
> The server that's running it is a home computer with a VPS installed...
> It's not my dev environment :)
>
>
Home computer used for a production environment?  Wow.. I'm speechless.


> The information being searched is specifically phone numbers, and the
> bosses want to provide the public away to browse them, hence the
> pagination... Once I removed a COUNT from mysql it started working alot
> better... So I still need to provide a better pagination system, but it's
> working.
>
>
If just showing phone numbers only and no other information, what's the
point since there are already several other white and yellow pages on the
net?  There's even a reverse number look-up too.  There's also a well known
paid service for getting a DB of contacts (name, address, phone numbers of
persons and businesses).  Just out of curiosity, what is it that your boss
intend to offer that would stand out for already existing services?  I doubt
anyone would be sane enough to sit there and just browse through phone
numbers only.  Even if it does show the owner's name of the registered
number, I highly doubt anyone sane would browse unless you provide some kind
of filter/search.


> Oh, and the 89 million is just for one state :) We are talking the
> possibility of I believe 10 billion numbers to cover the US, not to mention
> Canada which I believe uses the same numbering system as we do so that could
> be another 10 billion...
>
> >
> > As I've mentioned, something of this magnitude is better to leave it to
> the
> > DBA and work together with that DBA.  Either hire/contract one or become
> one
> > :)
>
> I'm working on becoming one ontop of web designer and programmer :)
>

Good luck, that's a LOT of reading.  I'd estimate that's about 3k+ pages of
reading. :)


> >
> >
> > Regards,
> > Tommy
>
>

--- End Message ---
--- Begin Message ---
On Mon, Oct 24, 2011 at 6:50 PM, Jason Pruim <li...@pruimphotography.com>wrote:

> Now that I've managed to list 3 separate programming languages and somewhat
> tie it back into php here's the question...
>
> I have about 89 million records in mysql... the initial load of the page
> takes 2 to 3 minutes, I am using pagination, so I have LIMIT's on the SQL
> query's... But they just aren't going fast enough...
>
> What I would like to do, is pull the data out of MySQL and store it in the
> HTML files, and then update the HTML files once a day/week/month... I can
> figure most of it out... BUT... How do I automatically link to the
> individual pages?
>
> I have the site working when you pull it from MySQL... Just the load time
> sucks... Any suggestions on where I can pull some more info from? :)
>
> Thanks in advance!
>

dial in the db schema (think keys) and queries; then investigate a reverse
proxy like varnish to cache the generated html.

you'll be able to handle a couple thousand requests per second against the
proxy in no time.

might be worth pre-generating some of the pages if they are still really
slow after db optimization.

-nathan

--- End Message ---
--- Begin Message ---
On 17 October 2011 22:57, Don Wieland <d...@dwdataconcepts.com> wrote:
> select timediff(cast(out_1 as time), cast(in_1 as time)) tHours FROM
> lm_tc_trans WHERE tc_trans_id = '42'

Can you try ...

SELECT
        CAST
                (
                TIMEDIFF
                        (
                        CAST(Out_1 AS Time),
                        CAST(In_1 AS Time)
                        )
                AS Decimal(5,2)
                ) tHours
FROM
        lm_tc_trans
WHERE
        tc_trans_id = '42'

Basically, CAST the result back to a decimal(5,2)
-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370

--- End Message ---
--- Begin Message ---
On 21 October 2011 17:27, Daniel Brown <danbr...@php.net> wrote:
>    I'll get this week's Friday distraction kicked off here with
> something shared with me by a Facebook friend.  If you're on Facebook,
> try this.  It's pretty sweet (and safe for work and kids).
>
>        http://www.takethislollipop.com/

Sweet? SWEET!? What sort of sicko are you???

I've got a deranged nutter hunting me down.

He looks a LOT like you!!!!





Cool though.
-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370

--- End Message ---
--- Begin Message ---
i have an array like

  [0] => Array
(
[likes] => 113091
  [name] => blabla
  [access_token] => AAABZCTx
[id] => 188206217874932

)

  [1] => Array
(
[likes] => 113091
[name] => blabla
[access_token] =>   AAABZCTz
[id] => 188206217874932
   )

i want to filter the array by [id] sub value?

--- End Message ---
--- Begin Message ---
>
> i want to filter the array by [id] sub value?
>

The PHP manual is a source of infinite knowledge.  A simple entry of "array" 
in the "search for" field brings up just what you need.  Have at it! 



--- End Message ---
--- Begin Message ---
I have the following:

if (isset($argc)) {
    if ($argc == 1 || $argc > 2 || !preg_match("(\d{4}-\d{2}-\d{2})",
$argv[1])) {
        echo "\nUsage: $argv[0] <yyyy-mm-dd>\n\n";
        exit;
    } else {
        $base_date = $argv[1];
    }
} else {
    $base_date = date('Y-m-d');
}

When I run it:

 $ ./process_patches.php 201-01-01

Usage: ./process_patches.php <yyyy-mm-dd>

patches@innm2 ~/Code/Oculi $ ./process_patches.php 2011-011-01

Usage: ./process_patches.php <yyyy-mm-dd>

patches@innm2 ~/Code/Oculi $ ./process_patches.php 2011-01-011

Works..

What am I doing wrong?

Thanks!

-- 
Paul Halliday
http://www.squertproject.org/

--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Paul Halliday [mailto:paul.halli...@gmail.com] 
Sent: Thursday, October 27, 2011 2:43 PM
To: PHP-General
Subject: [PHP] What is wrong with this preg_match?

I have the following:

if (isset($argc)) {
    if ($argc == 1 || $argc > 2 || !preg_match("(\d{4}-\d{2}-\d{2})",
$argv[1])) {
        echo "\nUsage: $argv[0] <yyyy-mm-dd>\n\n";
        exit;
    } else {
        $base_date = $argv[1];
    }
} else {
    $base_date = date('Y-m-d');
}

When I run it:

 $ ./process_patches.php 201-01-01

Usage: ./process_patches.php <yyyy-mm-dd>

patches@innm2 ~/Code/Oculi $ ./process_patches.php 2011-011-01

Usage: ./process_patches.php <yyyy-mm-dd>

patches@innm2 ~/Code/Oculi $ ./process_patches.php 2011-01-011

Works..

What am I doing wrong?

Thanks!

--
Paul Halliday
http://www.squertproject.org/


Paul,

To me, it looks like you're just getting the next 2 digits, so 2011-01-011 is 
getting 2011-01-01 and truncating the last 1.

If you had used (I think)  "^(\d{4}-\d{2}-\d{2})$"  I think that would give you 
what you want... (but my reg-ex is horrible)

Steve

--- End Message ---
--- Begin Message ---
On 10/27/11 11:43, "Paul Halliday" <paul.halli...@gmail.com> wrote:


>    if ($argc == 1 || $argc > 2 || !preg_match("(\d{4}-\d{2}-\d{2})",
>
>Usage: ./process_patches.php <yyyy-mm-dd>
>
>patches@innm2 ~/Code/Oculi $ ./process_patches.php 2011-01-011

The problem is that your expression basically defines a 'contains'-type
search, so it's matching the first 10 characters as required but then
simply ignoring that last, 11th character because there's no requirement
regarding it in the expression.

Try this instead:

        ^(\d{4}-\d{2}-\d{2})$

The ^ anchors the matching string to the beginning of the string, while
the $ anchors it to the end, which effectively forces the expression to
match the entire string, disallowing extra characters before or after it.


Regards,
Bob
--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/







Notice: This communication, including attachments, may contain information that 
is confidential. It constitutes non-public information intended to be conveyed 
only to the designated recipient(s). If the reader or recipient of this 
communication is not the intended recipient, an employee or agent of the 
intended recipient who is responsible for delivering it to the intended 
recipient, or if you believe that you have received this communication in 
error, please notify the sender immediately by return e-mail and promptly 
delete this e-mail, including attachments without reading or saving them in any 
manner. The unauthorized use, dissemination, distribution, or reproduction of 
this e-mail, including attachments, is prohibited and may be unlawful. If you 
have received this email in error, please notify us immediately by e-mail or 
telephone and delete the e-mail and the attachments (if any).

--- End Message ---

Reply via email to