php-general Digest 14 Sep 2009 13:03:51 -0000 Issue 6339

Topics (messages 297985 through 298004):

Re: APC - Upload progress problem. apc
        297985 by: Phred White
        297986 by: Phred White
        297987 by: Eddie Drapkin
        297988 by: Phred White
        297990 by: Phred White
        297991 by: Eddie Drapkin
        298001 by: Phred White

server name that the user agent used
        297989 by: Tom Worster
        297994 by: Tommy Pham
        298004 by: Tom Worster

Apache's mod_dbd connection pool
        297992 by: Tommy Pham

Re: get an object property
        297993 by: Tom Worster
        297997 by: Lars Torben Wilson

Question: Sorting through table headers?
        297995 by: Parham Doustdar
        297996 by: Tommy Pham
        297999 by: Jim Lucas
        298002 by: Marcus Gna?
        298003 by: Tony Marston

Re: [Formaldehyde] The Most Basic Ajax - PHP Error Debugger
        297998 by: J DeBord

Re: Fixing the path
        298000 by: Arno Kuhl

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 Sep 11, 2009, at 1:17 PM, Eddie Drapkin wrote:

On Fri, Sep 11, 2009 at 1:02 PM, Phred White <[email protected]> wrote:
Hey folks..

Anybody ever use APC to show upload progress?

It sounds really cool, but apc_fetch always returns false a value for
uploads. I can apc_add something and fetch it, but not for uploads : (
(set-up: php-apc 3.0.19, Apache2, php 5.2.10, no suhosin patch)

There is little info to google on this, and I've been through it.

I was hoping some hard core, tireless, php programmer just knew the answer.

With high anxiety, Phred





I recently had to do roughly the same thing (visual upload progress)
and I had done some research into APC.  What I learned was that the
upload tracking didn't work with FastCGI (which would have prevented
our switch to nginx, but not a deal breaker) and what broke the deal,
though, was the fact that APC's upload progress is apparently not
thread safe, so if person A is uploading a file and person B starts an
upload, you get a silent failure.  Which brings me to another point,
it seems to silently fail.

Ultimately, I went with a flash based solution because the APC
solution had way too many problems to be really useful.  It's a nice
thought, but I wouldn't recommend it.  I know this isn't exactly what
you wanted, but I had a similar experience and thought I would share
:)

Dang! You are exactly right - that isn't what I wanted to hear! : (
But better to know now, then when my timeline is already used up.

Did you write your own flash based solution, or use an canned one?

Thanks, Phred


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

On Sep 11, 2009, at 4:01 PM, tedd wrote:

At 2:17 PM -0400 9/11/09, Eddie Drapkin wrote:
On Fri, Sep 11, 2009 at 1:02 PM, Phred White <[email protected]> wrote:
Hey folks..

> Anybody ever use APC to show upload progress?

Nope, I choose not to complicate my life.  :-)

Instead, I give the user one of these:

http://webbytedd.com/bb/wait/

Besides, what does the user have to know anyway that makes it so important that they see a progress bar?

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

those are SWEET! That page is going to become one of my favorite pages just to look at for therapeutic purposes : )

Unfortunately, my folks will be uploading a gig at a crack, so the really need to know what is actually going on!


--- End Message ---
--- Begin Message ---
On Sun, Sep 13, 2009 at 8:29 PM, Phred White <[email protected]> wrote:
>
> On Sep 11, 2009, at 1:17 PM, Eddie Drapkin wrote:
>
>> On Fri, Sep 11, 2009 at 1:02 PM, Phred White <[email protected]>
>> wrote:
>>>
>>> Hey folks..
>>>
>>> Anybody ever use APC to show upload progress?
>>>
>>> It sounds really cool, but apc_fetch always returns false a value for
>>> uploads. I can apc_add something and fetch it, but not for uploads : (
>>> (set-up: php-apc 3.0.19, Apache2, php 5.2.10, no suhosin patch)
>>>
>>> There is little info to google on this, and I've been through it.
>>>
>>> I was hoping some hard core, tireless, php programmer just knew the
>>> answer.
>>>
>>> With high anxiety, Phred
>>>
>>>
>>>
>>>
>>
>> I recently had to do roughly the same thing (visual upload progress)
>> and I had done some research into APC.  What I learned was that the
>> upload tracking didn't work with FastCGI (which would have prevented
>> our switch to nginx, but not a deal breaker) and what broke the deal,
>> though, was the fact that APC's upload progress is apparently not
>> thread safe, so if person A is uploading a file and person B starts an
>> upload, you get a silent failure.  Which brings me to another point,
>> it seems to silently fail.
>>
>> Ultimately, I went with a flash based solution because the APC
>> solution had way too many problems to be really useful.  It's a nice
>> thought, but I wouldn't recommend it.  I know this isn't exactly what
>> you wanted, but I had a similar experience and thought I would share
>> :)
>
> Dang! You are exactly right - that isn't what I wanted to hear! : (
> But better to know now, then when my timeline is already used up.
>
> Did you write your own flash based solution, or use an canned one?
>
> Thanks, Phred
>
>

I actually wound up using swfupload because of a friend's
recommendation and also because there's a nifty jQuery plugin for it.

The project's main site: http://swfupload.org
The jQuery plugin I'm using:
http://blogs.bigfish.tv/adam/2009/06/14/swfupload-jquery-plugin/

The *only* issue I could find with a flash based uploader (I don't
regard flash installation as an issue because we're a video based site
and well, if you're using our site to watch videos...) was there's an
as-of-yet unresolved bug in linux flash clients that locks a browser
until upload is completed.  Adobe's bug tracker seems to be down for
me at the moment, but if you really want the bug, let me know offlist
and I'll supply it later. :)

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

On Sep 13, 2009, at 7:34 PM, Eddie Drapkin wrote:

On Sun, Sep 13, 2009 at 8:29 PM, Phred White <[email protected]> wrote:

On Sep 11, 2009, at 1:17 PM, Eddie Drapkin wrote:

On Fri, Sep 11, 2009 at 1:02 PM, Phred White <[email protected] >
wrote:

Hey folks..

Anybody ever use APC to show upload progress?

It sounds really cool, but apc_fetch always returns false a value for uploads. I can apc_add something and fetch it, but not for uploads : (
(set-up: php-apc 3.0.19, Apache2, php 5.2.10, no suhosin patch)

There is little info to google on this, and I've been through it.

I was hoping some hard core, tireless, php programmer just knew the
answer.

With high anxiety, Phred





I recently had to do roughly the same thing (visual upload progress)
and I had done some research into APC.  What I learned was that the
upload tracking didn't work with FastCGI (which would have prevented
our switch to nginx, but not a deal breaker) and what broke the deal,
though, was the fact that APC's upload progress is apparently not
thread safe, so if person A is uploading a file and person B starts an
upload, you get a silent failure.  Which brings me to another point,
it seems to silently fail.

Ultimately, I went with a flash based solution because the APC
solution had way too many problems to be really useful.  It's a nice
thought, but I wouldn't recommend it. I know this isn't exactly what
you wanted, but I had a similar experience and thought I would share
:)

Dang! You are exactly right - that isn't what I wanted to hear! : (
But better to know now, then when my timeline is already used up.

Did you write your own flash based solution, or use an canned one?

Thanks, Phred



I actually wound up using swfupload because of a friend's
recommendation and also because there's a nifty jQuery plugin for it.

The project's main site: http://swfupload.org
The jQuery plugin I'm using:
http://blogs.bigfish.tv/adam/2009/06/14/swfupload-jquery-plugin/

The *only* issue I could find with a flash based uploader (I don't
regard flash installation as an issue because we're a video based site
and well, if you're using our site to watch videos...) was there's an
as-of-yet unresolved bug in linux flash clients that locks a browser
until upload is completed.  Adobe's bug tracker seems to be down for
me at the moment, but if you really want the bug, let me know offlist
and I'll supply it later. :)

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


Thanks Eddie. I will look into it.
I agree, if you don't have Flash use your telegraph or something. Sheesh! (iPhone users excepted - they morn their lack of Flash)



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

On Sep 13, 2009, at 7:34 PM, Eddie Drapkin wrote:

On Sun, Sep 13, 2009 at 8:29 PM, Phred White <[email protected]> wrote:

On Sep 11, 2009, at 1:17 PM, Eddie Drapkin wrote:

On Fri, Sep 11, 2009 at 1:02 PM, Phred White <[email protected] >
wrote:

Hey folks..

Anybody ever use APC to show upload progress?

It sounds really cool, but apc_fetch always returns false a value for uploads. I can apc_add something and fetch it, but not for uploads : (
(set-up: php-apc 3.0.19, Apache2, php 5.2.10, no suhosin patch)

There is little info to google on this, and I've been through it.

I was hoping some hard core, tireless, php programmer just knew the
answer.

With high anxiety, Phred





I recently had to do roughly the same thing (visual upload progress)
and I had done some research into APC.  What I learned was that the
upload tracking didn't work with FastCGI (which would have prevented
our switch to nginx, but not a deal breaker) and what broke the deal,
though, was the fact that APC's upload progress is apparently not
thread safe, so if person A is uploading a file and person B starts an
upload, you get a silent failure.  Which brings me to another point,
it seems to silently fail.

Ultimately, I went with a flash based solution because the APC
solution had way too many problems to be really useful.  It's a nice
thought, but I wouldn't recommend it. I know this isn't exactly what
you wanted, but I had a similar experience and thought I would share
:)

Dang! You are exactly right - that isn't what I wanted to hear! : (
But better to know now, then when my timeline is already used up.

Did you write your own flash based solution, or use an canned one?

Thanks, Phred



I actually wound up using swfupload because of a friend's
recommendation and also because there's a nifty jQuery plugin for it.

The project's main site: http://swfupload.org
The jQuery plugin I'm using:
http://blogs.bigfish.tv/adam/2009/06/14/swfupload-jquery-plugin/

The *only* issue I could find with a flash based uploader (I don't
regard flash installation as an issue because we're a video based site
and well, if you're using our site to watch videos...) was there's an
as-of-yet unresolved bug in linux flash clients that locks a browser
until upload is completed.  Adobe's bug tracker seems to be down for
me at the moment, but if you really want the bug, let me know offlist
and I'll supply it later. :)

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

Hey Eddie:

One more question...
I have an existing form that provides other data that need to be linked to the file upload. It looks like swfupload, just uploads all by its lonesome. I also need the javascript form validator to be triggered before any uploading occurs. Is this possible? You don't have to tell me how (though I wouldn't mind a few clues). I just want to know if it will meet my needs once i dig in.

Thanks


--- End Message ---
--- Begin Message ---
On Sun, Sep 13, 2009 at 9:38 PM, Phred White <[email protected]> wrote:
>
> On Sep 13, 2009, at 7:34 PM, Eddie Drapkin wrote:
>
>> On Sun, Sep 13, 2009 at 8:29 PM, Phred White <[email protected]>
>> wrote:
>>>
>>> On Sep 11, 2009, at 1:17 PM, Eddie Drapkin wrote:
>>>
>>>> On Fri, Sep 11, 2009 at 1:02 PM, Phred White <[email protected]>
>>>> wrote:
>>>>>
>>>>> Hey folks..
>>>>>
>>>>> Anybody ever use APC to show upload progress?
>>>>>
>>>>> It sounds really cool, but apc_fetch always returns false a value for
>>>>> uploads. I can apc_add something and fetch it, but not for uploads : (
>>>>> (set-up: php-apc 3.0.19, Apache2, php 5.2.10, no suhosin patch)
>>>>>
>>>>> There is little info to google on this, and I've been through it.
>>>>>
>>>>> I was hoping some hard core, tireless, php programmer just knew the
>>>>> answer.
>>>>>
>>>>> With high anxiety, Phred
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> I recently had to do roughly the same thing (visual upload progress)
>>>> and I had done some research into APC.  What I learned was that the
>>>> upload tracking didn't work with FastCGI (which would have prevented
>>>> our switch to nginx, but not a deal breaker) and what broke the deal,
>>>> though, was the fact that APC's upload progress is apparently not
>>>> thread safe, so if person A is uploading a file and person B starts an
>>>> upload, you get a silent failure.  Which brings me to another point,
>>>> it seems to silently fail.
>>>>
>>>> Ultimately, I went with a flash based solution because the APC
>>>> solution had way too many problems to be really useful.  It's a nice
>>>> thought, but I wouldn't recommend it.  I know this isn't exactly what
>>>> you wanted, but I had a similar experience and thought I would share
>>>> :)
>>>
>>> Dang! You are exactly right - that isn't what I wanted to hear! : (
>>> But better to know now, then when my timeline is already used up.
>>>
>>> Did you write your own flash based solution, or use an canned one?
>>>
>>> Thanks, Phred
>>>
>>>
>>
>> I actually wound up using swfupload because of a friend's
>> recommendation and also because there's a nifty jQuery plugin for it.
>>
>> The project's main site: http://swfupload.org
>> The jQuery plugin I'm using:
>> http://blogs.bigfish.tv/adam/2009/06/14/swfupload-jquery-plugin/
>>
>> The *only* issue I could find with a flash based uploader (I don't
>> regard flash installation as an issue because we're a video based site
>> and well, if you're using our site to watch videos...) was there's an
>> as-of-yet unresolved bug in linux flash clients that locks a browser
>> until upload is completed.  Adobe's bug tracker seems to be down for
>> me at the moment, but if you really want the bug, let me know offlist
>> and I'll supply it later. :)
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
> Hey Eddie:
>
> One more question...
> I have an existing form that provides other data that need to be linked to
> the file upload. It looks like swfupload, just uploads all by its lonesome.
> I also need the javascript form validator to be triggered before any
> uploading occurs. Is this possible? You don't have to tell me how (though I
> wouldn't mind a few clues). I just want to know if it will meet my needs
> once i dig in.
>
> Thanks
>
>

That should all be possible.  I'd take a look at
http://demo.swfupload.org/v220/featuresdemo/index.php as that has most
of that happening on the page and you can bootleg some of their
example code :)

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

On Sep 13, 2009, at 8:50 PM, Eddie Drapkin wrote:

On Sun, Sep 13, 2009 at 9:38 PM, Phred White <[email protected]> wrote:

On Sep 13, 2009, at 7:34 PM, Eddie Drapkin wrote:

On Sun, Sep 13, 2009 at 8:29 PM, Phred White <[email protected] >
wrote:

On Sep 11, 2009, at 1:17 PM, Eddie Drapkin wrote:

On Fri, Sep 11, 2009 at 1:02 PM, Phred White <[email protected] >
wrote:

Hey folks..

Anybody ever use APC to show upload progress?

It sounds really cool, but apc_fetch always returns false a value for uploads. I can apc_add something and fetch it, but not for uploads : (
(set-up: php-apc 3.0.19, Apache2, php 5.2.10, no suhosin patch)

There is little info to google on this, and I've been through it.

I was hoping some hard core, tireless, php programmer just knew the
answer.

With high anxiety, Phred





I recently had to do roughly the same thing (visual upload progress) and I had done some research into APC. What I learned was that the upload tracking didn't work with FastCGI (which would have prevented our switch to nginx, but not a deal breaker) and what broke the deal,
though, was the fact that APC's upload progress is apparently not
thread safe, so if person A is uploading a file and person B starts an upload, you get a silent failure. Which brings me to another point,
it seems to silently fail.

Ultimately, I went with a flash based solution because the APC
solution had way too many problems to be really useful. It's a nice thought, but I wouldn't recommend it. I know this isn't exactly what you wanted, but I had a similar experience and thought I would share
:)

Dang! You are exactly right - that isn't what I wanted to hear! : (
But better to know now, then when my timeline is already used up.

Did you write your own flash based solution, or use an canned one?

Thanks, Phred



I actually wound up using swfupload because of a friend's
recommendation and also because there's a nifty jQuery plugin for it.

The project's main site: http://swfupload.org
The jQuery plugin I'm using:
http://blogs.bigfish.tv/adam/2009/06/14/swfupload-jquery-plugin/

The *only* issue I could find with a flash based uploader (I don't
regard flash installation as an issue because we're a video based site and well, if you're using our site to watch videos...) was there's an
as-of-yet unresolved bug in linux flash clients that locks a browser
until upload is completed.  Adobe's bug tracker seems to be down for
me at the moment, but if you really want the bug, let me know offlist
and I'll supply it later. :)

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

Hey Eddie:

One more question...
I have an existing form that provides other data that need to be linked to the file upload. It looks like swfupload, just uploads all by its lonesome.
I also need the javascript form validator to be triggered before any
uploading occurs. Is this possible? You don't have to tell me how (though I wouldn't mind a few clues). I just want to know if it will meet my needs
once i dig in.

Thanks



That should all be possible.  I'd take a look at
http://demo.swfupload.org/v220/featuresdemo/index.php as that has most
of that happening on the page and you can bootleg some of their
example code :)

Bummer... It looked so promising, but on Macs, Flash has to load the entire file into memory to upload! Rrrrrrrrr. So, it isn't viable for big files (Gig +) if you need it to be cross platform.

So now I am looking at perl of all things! If you have any ideas let me know. thanks for all your help so far.

Phred

--- End Message ---
--- Begin Message ---
when using apache with one vhost that responds to a few different hostnames,
e.g. domain.org, y.domain.org, x.domain.org, let's say the vhost's server
name is y.domain.org and the other two are aliases, is there a way in php to
know which of these was used by the user agent to address the server?



--- End Message ---
--- Begin Message ---
--- On Sun, 9/13/09, Tom Worster <[email protected]> wrote:

> From: Tom Worster <[email protected]>
> Subject: [PHP] server name that the user agent used
> To: "PHP General List" <[email protected]>
> Date: Sunday, September 13, 2009, 8:21 PM
> when using apache with one vhost that
> responds to a few different hostnames,
> e.g. domain.org, y.domain.org, x.domain.org, let's say the
> vhost's server
> name is y.domain.org and the other two are aliases, is
> there a way in php to
> know which of these was used by the user agent to address
> the server?
> 

Did you see what comes up with php_info() for
$_SERVER["SERVER_NAME"] or $_SERVER["HTTP_HOST"] ?

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

--- End Message ---
--- Begin Message ---
On 9/13/09 10:24 PM, "Tommy Pham" <[email protected]> wrote:

> --- On Sun, 9/13/09, Tom Worster <[email protected]> wrote:
> 
>> From: Tom Worster <[email protected]>
>> Subject: [PHP] server name that the user agent used
>> To: "PHP General List" <[email protected]>
>> Date: Sunday, September 13, 2009, 8:21 PM
>> when using apache with one vhost that
>> responds to a few different hostnames,
>> e.g. domain.org, y.domain.org, x.domain.org, let's say the
>> vhost's server
>> name is y.domain.org and the other two are aliases, is
>> there a way in php to
>> know which of these was used by the user agent to address
>> the server?
>> 
> 
> Did you see what comes up with php_info() for
> $_SERVER["SERVER_NAME"] or $_SERVER["HTTP_HOST"] ?

SERVER_NAME returns whatever apache has as the vhost's configured server
name.

the php manual says of HTTP_HOST: "Contents of the Host: header from the
current request, if there is one." in which the last 4 words are a little
off-putting. but:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23

i much more encouraging. the field is mandatory and should have what i'm
looking for. it's absence is cause for a 400. casual testing (with a modern
non-ie browser) seems to bear this out.

so i'll try using that with fallback to my current techniques if i don't
find a good value in HTTP_HOST.



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

Has anyone used Apache Httpd's mod_dbd connection pool in any of your PHP 
app/project?  Do you notice a performance increase from the overhead of 
establishing/closing a connection?

TIA,
Tommy

--- End Message ---
--- Begin Message ---
On 9/13/09 3:21 AM, "Lars Torben Wilson" <[email protected]> wrote:

>> On 9/12/09 9:50 AM, "Tom Worster" <[email protected]> wrote:
>>
>> but let me give you a more different example:
>> 
>> $a and $b are normally both objects, each with various members including a
>> prop q, but sometimes $a is false. i want the q of $a if $a isn't false,
>> otherwise that of $b.
>> 
>> ($a ? $a : $b)->q   // is not php, afaik
>> 
>> before you suggest one, i know there are simple workarounds.
>>   
> You're right, that isn't PHP syntax. One workaround that came to mind
> which does
> a similar thing (although using a different mechanism) is this:
> 
>   ${$a ? 'a' : 'b'}->q

i would not have thought of that. interesting...


>> and while i'm at it, and using my original error, how come...
>> 
>> function o() { return (object) array('q'=>7); }
>> echo o()->q;  // is ok syntax, but
>> 
>> function a() { return array('q'=>5); }
>> echo a()['q'];  // isn't?
>>   
> I'm afraid I can't answer that right now--it does perhaps seem
> inconsistent at first glance,
> although I can't say I've ever missed it or felt that using syntax like
> that would make my
> life any better. Maybe it would. Then again, I can also see an argument
> being made for
> allowing the object syntax but not the array syntax: in the case of
> objects, you can have
> a clean class declaration which is pretty much self-documenting, and
> later users of the
> class can have a clear idea of which properties are available and which
> are not, and they
> can thus be sure that o()->q will not result in uninitialized property
> problems. Using the
> array syntax you could never be sure that the index requested actually
> exists.
> 
> Of course, this holds true only for people like me who don't really like
> the idea of creating
> objects on the fly in PHP unless there's a very good reason to. Usually
> in PHP such tasks
> are better handled by arrays anyway.

the dbms abstraction library i use delivers rows, by default, as objects. so
i commonly handle dynamically generated data in the form of objects, though
it's not my code generating those objects. i think that's one reasons why i
often find i would use objects as data structures. and because i find the
dynamic objects in js convenient.

but i think you're preference reflects more closely was probably the concept
of php's version of oop: an object is an instances of a static class.

in any case, now that i've confirmed that i'm not merely unaware of the
features i was hunting for, and that they don't exist by design, i can
perhaps move on.

on a related note, way back when xml was ascendant as "the most exciting new
technology to hit the net since java", i was not impressed. what a horrid
syntax for specifying and communicating data, i would argue. why not use the
syntax from some sensible programming language instead? js, for example?
easy to parse, less overhead, human readable (i find xml hard to read), etc.
then eventually json happened, without all the hype and fanfare, just doing
the job very conveniently. i love it.

and to make that comment vaguely php related, i now use json to encode
structured data that i want to write to the php error log.



--- End Message ---
--- Begin Message ---
Tom Worster wrote:
On 9/13/09 3:21 AM, "Lars Torben Wilson" <[email protected]> wrote:

On 9/12/09 9:50 AM, "Tom Worster" <[email protected]> wrote:

but let me give you a more different example:

$a and $b are normally both objects, each with various members including a
prop q, but sometimes $a is false. i want the q of $a if $a isn't false,
otherwise that of $b.

($a ? $a : $b)->q   // is not php, afaik

before you suggest one, i know there are simple workarounds.
You're right, that isn't PHP syntax. One workaround that came to mind
which does
a similar thing (although using a different mechanism) is this:

  ${$a ? 'a' : 'b'}->q

i would not have thought of that. interesting...


and while i'm at it, and using my original error, how come...

function o() { return (object) array('q'=>7); }
echo o()->q;  // is ok syntax, but

function a() { return array('q'=>5); }
echo a()['q'];  // isn't?
I'm afraid I can't answer that right now--it does perhaps seem
inconsistent at first glance,
although I can't say I've ever missed it or felt that using syntax like
that would make my
life any better. Maybe it would. Then again, I can also see an argument
being made for
allowing the object syntax but not the array syntax: in the case of
objects, you can have
a clean class declaration which is pretty much self-documenting, and
later users of the
class can have a clear idea of which properties are available and which
are not, and they
can thus be sure that o()->q will not result in uninitialized property
problems. Using the
array syntax you could never be sure that the index requested actually
exists.

Of course, this holds true only for people like me who don't really like
the idea of creating
objects on the fly in PHP unless there's a very good reason to. Usually
in PHP such tasks
are better handled by arrays anyway.

the dbms abstraction library i use delivers rows, by default, as objects. so
i commonly handle dynamically generated data in the form of objects, though
it's not my code generating those objects. i think that's one reasons why i
often find i would use objects as data structures. and because i find the
dynamic objects in js convenient.

Yeah. . .never been a fan of the libs which return objects, although such a model does
perhaps have its uses.
but i think you're preference reflects more closely was probably the concept
of php's version of oop: an object is an instances of a static class.


Yes, I'd say the same thing, except I'd replace the term 'static' with 'declared'. If an object is created on the fly, in someone else's code, and I have to maintain that code, then either that code must be well-documented or I have to go on a hunt through the source code to find out what might be available within that object. Not my idea of fun. Convenient for the original coder, perhaps, especially if they come from an automatic model background such as Javascript. And maybe one day I'll come to love it. So far I haven't seen enough of a benefit to convince me that it's worth the long-term maintenance headache it can (note that I say "can", not "does") cause.

in any case, now that i've confirmed that i'm not merely unaware of the
features i was hunting for, and that they don't exist by design, i can
perhaps move on.

on a related note, way back when xml was ascendant as "the most exciting new
technology to hit the net since java", i was not impressed. what a horrid
syntax for specifying and communicating data, i would argue. why not use the
syntax from some sensible programming language instead? js, for example?
easy to parse, less overhead, human readable (i find xml hard to read), etc.
then eventually json happened, without all the hype and fanfare, just doing
the job very conveniently. i love it.

I also never found myself sold on the "XML everywhere" philosophy which seemed to spring up during its first few years. I have found it useful for certain things--usually involving documents. :) It's awesome for technical documentation such as working on the PHP manual; I've used it when writing books; and XML and the DOM can be a great help when constructing automatically validated XHTML. But there are also many other things which people insisted it would be perfect for which just end up being a waste of cycles and memory. It's a good tool for some tasks but completely ill-suited
for others IMHO.

I like the idea of json when working with Javascript. Years ago (before var_export()) I wrote something very similar to var_export() which would write out a human-readable and directly PHP-parseable string for structured data. Sort of like. . .er. . .pson (*cough*). ;)
and to make that comment vaguely php related, i now use json to encode
structured data that i want to write to the php error log.
Interesting. For something like that I would just use var_export() and skip the overhead of parsing json back into PHP if I needed to do that. I'd use json when using Javascript, though. But whatever makes you happy--I'm certainly not here to try to change anybody's mind
about that sort of thing.

Cheers, and good luck with the explorations!


Regards,

Torben

--- End Message ---
--- Begin Message ---
Hello there,
I've been asked to create something like the tables you usually see, where the 
headers are actually links and when you click the links, the table gets sorted 
based on the header. Are there any classes that you know of that would do the 
job? My current idea is to return an array of the colomn which contains the 
data you want to sort on (like 'name') then sort the array and do something 
like:
[code]
for (i = 0; i < length(array); i++)
mysql_query("select * from table where 'name' = ${aray[i]}");
[/code]
Any better algorithms anyone?
Thanks!
-- 
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
GoogleTalk: [email protected]
Twitter: PD90
email: parham90 at GMail dot com

--- End Message ---
--- Begin Message ---
--- On Sun, 9/13/09, Parham Doustdar <[email protected]> wrote:

> From: Parham Doustdar <[email protected]>
> Subject: [PHP] Question: Sorting through table headers?
> To: [email protected]
> Date: Sunday, September 13, 2009, 6:55 AM
> Hello there,
> I've been asked to create something like the tables you
> usually see, where the headers are actually links and when
> you click the links, the table gets sorted based on the
> header. Are there any classes that you know of that would do
> the job? My current idea is to return an array of the colomn
> which contains the data you want to sort on (like 'name')
> then sort the array and do something like:
> [code]
> for (i = 0; i < length(array); i++)
> mysql_query("select * from table where 'name' =
> ${aray[i]}");
> [/code]

Your code looks like you're filtering and not sorting. You should revisit the 
basics of SQL syntax.

> Any better algorithms anyone?
> Thanks!
> -- 
> ---
> Contact info:
> Skype: parham-d
> MSN: fire_lizard16 at hotmail dot com
> GoogleTalk: [email protected]
> Twitter: PD90
> email: parham90 at GMail dot com

--- End Message ---
--- Begin Message ---
Parham Doustdar wrote:
Hello there,
I've been asked to create something like the tables you usually see, where the 
headers are actually links and when you click the links, the table gets sorted 
based on the header. Are there any classes that you know of that would do the 
job? My current idea is to return an array of the colomn which contains the 
data you want to sort on (like 'name') then sort the array and do something 
like:
[code]
for (i = 0; i < length(array); i++)
mysql_query("select * from table where 'name' = ${aray[i]}");
[/code]
Any better algorithms anyone?
Thanks!

My suggestion would be to have the client do it.

http://www.js-vault.us/iscripts/007.html

I use it on a number of different pages.
--
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

--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
> Parham Doustdar wrote:
>> Hello there,
>> I've been asked to create something like the tables you usually see,
>> where the headers are actually links and when you click the links, the
>> table gets sorted based on the header. Are there any classes that you
>> know of that would do the job? My current idea is to return an array
>> of the colomn which contains the data you want to sort on (like
>> 'name') then sort the array and do something like:
>> [code]
>> for (i = 0; i < length(array); i++)
>> mysql_query("select * from table where 'name' = ${aray[i]}");
>> [/code]
>> Any better algorithms anyone?
>> Thanks!
> 
> My suggestion would be to have the client do it.
> 
> http://www.js-vault.us/iscripts/007.html
> 
> I use it on a number of different pages.

This could be done clientside if you intend to show all data. If you
want to implement paging too, you have to do it on the server though.

--- End Message ---
--- Begin Message ---
What you are trying to do is ridiculously easy, and something which I 
accomplished years ago. Basically every column heading needs to be output as 
a hyperlink which repeats the current page with the addition of 
"orderby=<column_name>" in the URL. This information appears in the $_GET 
array, so you just repeat the previous sql query with the addition of an 
ORDER BY clause.

This assumes that you have already taken care of caching the query and 
paginating the results.

You cannot do this in a separate class as it requires action in both the 
presentation (UI) and data access layers, and a single class is not allowed 
to operate in more than one layer.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

""Parham Doustdar"" <[email protected]> wrote in message 
news:[email protected]...
Hello there,
I've been asked to create something like the tables you usually see, where 
the headers are actually links and when you click the links, the table gets 
sorted based on the header. Are there any classes that you know of that 
would do the job? My current idea is to return an array of the colomn which 
contains the data you want to sort on (like 'name') then sort the array and 
do something like:
[code]
for (i = 0; i < length(array); i++)
mysql_query("select * from table where 'name' = ${aray[i]}");
[/code]
Any better algorithms anyone?
Thanks!
-- 
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
GoogleTalk: [email protected]
Twitter: PD90
email: parham90 at GMail dot com 



--- End Message ---
--- Begin Message ---
On Mon, Sep 14, 2009 at 2:05 AM, tedd <[email protected]> wrote:

> At 10:49 PM +0200 9/13/09, Andrea Giammarchi wrote:
>
>> I was expecting somebody that develop massive Ajax application, not a link
>> with 3 pages and zero point about the reply.
>>
>
> You asked if anyone did any ajax? So, I replied and provided you with an
> example.
>
> Who cares if my example only has three pages? It could be hundreds -- the
> technique scales.
>
> In all fairness Tedd, your example is a bit of a joke. Send some JSON back
and forth, do some database queries, and use a webservice all at the same
time. Your AJAX calls won't be so simple then.

I think the point of Andrea's project is to make debugging easier. Just like
firebug and Charles do in their own respect. Is it something you can do
without? Yes, especially if you have  a great development environment set
up. Is is something that could make inspecting what is getting thrown around
in your AJAX calls and the PHP errors that occur easier? Yes, especially
when sending JSON or remote object calls.

Charles is a great tool when doing Flash and Flex remoting, and AJAX. I have
the impression that Andrea's tool is perhaps doing something similar, but
taking it a step further. Maybe not everyone's cup of tea, but I think it is
difficult to write off as useless.

In any event, I provided you an example that does not need your debugger --
> it works and works good.
>
> But then you get all testy because I did not read your documentation. I
> never said I did AND there was never any requirement for me to do so before
> posting. I was simply replying to your question.
>
> But instead of establishing a constructive line of communication, you start
> off my criticizing me because I didn't read your documentation.
>
> You ask not to be treated as a noob, but you come in here telling others
> where to get off and bragging about your credentials (as if the rest of us
> can't do better) -- I'm not sure who you think you are, but you sure act
> like an noob.
>
> If nothing else, you have a lot to learn about making a point.
>
>
> tedd
>
>
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>

--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Rico Secada [mailto:[email protected]] 

Some time ago I developed a small web application that a bunch of users has
installed.

I have always used the DOCUMENT_ROOT for my includes, but the other day I
installed the application in a subdirectory, and as you've guessed a lot of
the includes didn't work.

I have been reading up on the subject of absolute vs. relative paths etc.
And on the subject of defining your own document root.

I need the application to be as user friendly as possible, and I would like
to avoid having users enter path details in the configuration.

What is the best way to solve this problem?

Rico.
--

Who are your users? Can users download the script and run it on their own
servers? If so there shouldn't be a problem asking them to set a path in a
config file because presumably the users would know something about servers
and paths, and presumably they'll know enough to create the directory and
copy the files there in the first place.

If you have an install process you can pick up the current directory from
system globals and write it to the path setting in the config file. You
might need two different absolute paths, one for includes and one for urls.

Cheers
Arno


--- End Message ---

Reply via email to