|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 6 Jun 2006 16:47:01 -0000 Issue 4170
php-general-digest-help
lists.php.net
Date: Tue Jun 06 2006 - 11:47:01 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 6 Jun 2006 16:47:01 -0000 Issue 4170
Topics (messages 237441 through 237465):
Re: When is "z" != "z" ?
237441 by: Robert Cummings
237452 by: Ford, Mike
237453 by: Finner, Doug
237456 by: Martin Alterisio
237458 by: Rasmus Lerdorf
237459 by: Barry
237460 by: Martin Alterisio
237461 by: Martin Alterisio
237465 by: Robert Cummings
Cannot read variables
237442 by: William Stokes
237448 by: The Panister
237451 by: David Otton
237454 by: William Stokes
237462 by: Adam Zey
Removing an aspect of a variable...
237443 by: Rob W.
237444 by: Rob W.
237445 by: Peter Lauri
237446 by: Robin Vickery
237447 by: Paul Novitski
237450 by: David Otton
Re: Session variables on Windows
237449 by: The Panister
Re: Using variable content to name a class
237455 by: Jochem Maas
Pear DB and memcached
237457 by: Ruben Rubio Rey
237463 by: Ben Ramsey
237464 by: Ruben Rubio Rey
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
On Tue, 2006-06-06 at 00:01, Martin Alterisio wrote:
> > Because defining ++ and < and > in such a way as to make them "behave like
> > numbers" would have made them not work for alphabetizing. A string is a
> > string, and comparison of strings is alphabetic (for some definition of
> > alphabet). It's more useful to deal with strings as strings than to make
> > them quack like numbers.
> >
>
> Then, if it's not a math operation, why use a math operator for such
> functionality? In which way is the ++ operator that generates a string
I don't ever remember seeing ++ in math class. I do remember seeing it
in lots of computer classes and to that end it was "just an operator"
with whatever semantic meaning was applied to it for a given language. I
guess it's usually to increment an integer, but that's just "in
general". I mean if we want to get into "math" operators being used for
string purposes, then we should look at how many languages use the "+"
operator to concatenate two strings -- by your accounts they should
treat their operands as integers and do a rote addition.
> sequence, useful enough to justify the formal inconsistency between the math
> operators? I still don't see the advantages of having the ++ recognize the
> string as a sequence, and generate the next item in the sequence. I believe
> those decisions should be left to the coder, because he knows what the
> string really represents and which kind of sequence is being used.
In C++ they do leave it to the coder, and well, we all know what a mess
it can be deciphering overloaded operators in C++ (or maybe we ALL
don't). At any rate, the PHP overlords made a choice, and IMHO the best
choice. For such a fringe issue I don't see what the argument is all
about. If you want the functionality you get in C by incrementing a
char, then use the chr() function on an integer.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
On 06 June 2006 02:35, tedd wrote:
>
> a b c ... x y z aa ab ac ... yx yy yz za zb zc ... zy zx zz aaa aab
>
> -- it's not!
Yes it is. The ++ operator generates that sequence when applied to a string, and nothing you can say or do will alter that fact.
You're trying to treat the 2nd and 3rd elements of the for () statement as an integrated unit, but they're not - the 2nd element generates the elements of the sequence in whatever order it generates in, and the 3rd element simply applies a test to the generated values and causes the sequence to stop the first time the test fails -- it's not in any way a limiter for what values will be generated.
Using simple integers, I could code something like this, which would exhibit similar properties:
for ($i=0; $i=($i+7)%100; $i<99)
The expression $i=($i+7)%100 is a generator for all integers in the set [0,100], but in a non-linear order; the test $i<99 will cause the loop to stop part way through the generated sequence, before some of the values which would satisfy the test have been produced.
> You can't say that "a" and "aaa" are members of a set
> identified as < "z" and then step through all the members of
> that population (an infinite group) and not include "aaa" --
> UNLESS -- you arbitrarily determine an end point for a much
> smaller sub-set.
See argument above: you're not stepping through all members of the set < "z" -- or even, as in the original loop, <= "z" -- you're stepping through all members of the set of strings containing any number of the characters [a-z] in any combination, in the order defined by the ++ operator, and terminating on the first generated element which is *not* <= "z". There's nothing in there that says you have to generate *all* strings <= "z" before terminating -- just that you stop on generating one that isn't.
> Now, unless, there is something that I don't see, which
> certainly could be the case, then php designers could have
> just as easily ended the loop at "z" and dispensed with this
> quirk all together.
Well, if the quirk were eliminated by making "z"++ be the next character in the ASCII sequence, the loop would still not end at "z" -- it would end on encountering "{" (if I remember my ASCII correctly).
> Besides, what's the point of having 676 character between a
> and z? Is there one?
No. And there aren't. There are 676 *strings", of length 1 and 2, as generated by the ++ operator.
You have to remember that there is no such type as 'character' in PHP -- just strings of length 1. And strings don't (necessarily) behave like characters.
> But this is the way it is and I except that -- but as Dirty
> Harry once said "A man's got to know his limitations" -- this
> not only applies to men and programmers, but also for
> languages as well.
>
> For example, the Unicode issue was raised during this
> discussion -- if php doesn't consider the numeric
> relationship of characters, then I see a big problem waiting
> in the wings. Because if we're having these types of
> discussions with just considering 00-7F characters, then I
> can only guess at what's going to happen when we start
> considering 000000-FFFFFF code-points.
Well, the PHP manual says: "Note that character variables can be incremented but not decremented and even so only plain ASCII characters (a-z and A-Z) are supported." If that continues to be the case, then the Unicode argument may be moot.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford
leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
attached mail follows:
I love this thread. Who'da thunk alphabets could be so much fun?
FWIW:
Different language, different rules - to do 'letter math', letters must
be converted to their ASCII number value, add one, convert back to a
letter. The set of allowed ASCII numbers is limited to (I think) 256
and 'real' letters are a subset of that collection.
Going from a-z was easy. Once you hit z, you reverted character 1 to a,
then looped a-z for character 2, repeat as required.
There were only a couple of ways to evaluate a string's 'size';
alphabetical and length. Each comparison generated different results
and one had to choose the comparison method based on the particular
requirements. In order to convert a string to some numeric value, I
believe I had to do it letter-by-letter and derive my own 'value' for
the string which would be mostly useless.
While the specific language methods differ from PHP (the language did
not allow anything like 'a'++ so this particular discussion couldn't
happen), it doesn't seem to me that the philosophical underpinnings are
all that different - letters are special. They look and behave
differently depending on the particular microscope you happen to be
using.
Anybody want to talk about rounding? ;-)
Doug
_______________________________________________________________________
This e-mail message has been sent by Kollsman, Inc. and is for the use
of the intended recipients only. The message may contain privileged
or confidential information. If you are not the intended recipient
you are hereby notified that any use, distribution or copying of
this communication is strictly prohibited, and you are requested to
delete the e-mail and any attachments and notify the sender immediately.
attached mail follows:
2006/6/6, Robert Cummings <robert
interjinn.com>:
>
> On Tue, 2006-06-06 at 00:01, Martin Alterisio wrote:
> > > Because defining ++ and < and > in such a way as to make them "behave
> like
> > > numbers" would have made them not work for alphabetizing. A string is
> a
> > > string, and comparison of strings is alphabetic (for some definition
> of
> > > alphabet). It's more useful to deal with strings as strings than to
> make
> > > them quack like numbers.
> > >
> >
> > Then, if it's not a math operation, why use a math operator for such
> > functionality? In which way is the ++ operator that generates a string
>
> I don't ever remember seeing ++ in math class. I do remember seeing it
> in lots of computer classes and to that end it was "just an operator"
> with whatever semantic meaning was applied to it for a given language. I
> guess it's usually to increment an integer, but that's just "in
> general". I mean if we want to get into "math" operators being used for
> string purposes, then we should look at how many languages use the "+"
> operator to concatenate two strings -- by your accounts they should
> treat their operands as integers and do a rote addition.
>
> > sequence, useful enough to justify the formal inconsistency between the
> math
> > operators? I still don't see the advantages of having the ++ recognize
> the
> > string as a sequence, and generate the next item in the sequence. I
> believe
> > those decisions should be left to the coder, because he knows what the
> > string really represents and which kind of sequence is being used.
>
> In C++ they do leave it to the coder, and well, we all know what a mess
> it can be deciphering overloaded operators in C++ (or maybe we ALL
> don't). At any rate, the PHP overlords made a choice, and IMHO the best
> choice. For such a fringe issue I don't see what the argument is all
> about. If you want the functionality you get in C by incrementing a
> char, then use the chr() function on an integer.
>
>
You're right about ++ operator not to be considered a math operator, my
mistake. What I should have said is that the usual connotation and expected
behaviour of ++ and the comparison operators is to give iteration
capabilities to a certain data type, as used in a for statement. For that to
happen certain constrains must be true for these operators, one of them
being: any < ++any, which is not true for the way these operators behave in
php.
I'm not saying "It's wrong let's change it right away!", I completely agree
that these rules can be bent on a not strongly typed language. The point I'm
trying to make, the thing I want to understant without a trace of doubt, is:
is it really worthy the functionality supplied with the string ++ operator
as it is? I don't see its usefullness yet.
attached mail follows:
Martin Alterisio wrote:
> You're right about ++ operator not to be considered a math operator, my
> mistake. What I should have said is that the usual connotation and expected
> behaviour of ++ and the comparison operators is to give iteration
> capabilities to a certain data type, as used in a for statement. For
> that to
> happen certain constrains must be true for these operators, one of them
> being: any < ++any, which is not true for the way these operators behave in
> php.
>
> I'm not saying "It's wrong let's change it right away!", I completely agree
> that these rules can be bent on a not strongly typed language. The point
> I'm
> trying to make, the thing I want to understant without a trace of doubt,
> is:
> is it really worthy the functionality supplied with the string ++ operator
> as it is? I don't see its usefullness yet.
It has been in PHP from the very beginning. So 10+ years. In that time
it has been sparingly used, granted, but at the same time it really
hasn't gotten in the way and removing it would break a number of legacy
applications.
There were a lot more operators that worked on strings in the early
days. '*' would do a cross-product, for example, treating the two
string operands as vectors and returning a vector orthogonal to both of
these. But I got tired of trying to explain to people what a cross
product was and how strings mapped to vectors in Euclidean space and
removed that. You could also at one point do "abc"-"b" to get "ac".
-Rasmus
attached mail follows:
Martin Alterisio schrieb:
> is it really worthy the functionality supplied with the string ++ operator
> as it is? I don't see its usefullness yet.
guess you want to order something by "name" not by number which might be
false in some cases (1,10,2,20,21 ... and so on).
There it might be useful.
Well i don think it is wrong behavior in that way.
because having looping from a till z you wil get "aa" after z so that
means aa is "higher" as z internally.
but looping till "aa" dont brings out a-z like you get a-y when you loop
till z (remember: for $i = a; $i <= z; $i++ gives the chars a-yz z right
followed by "aa")
Well if you implement something like that into a programming language it
should at least have some kind of logic behavior. Don't you think?
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
attached mail follows:
2006/6/6, Barry <barry
flyerheaven.de>:
>
> Martin Alterisio schrieb:
>
> > is it really worthy the functionality supplied with the string ++
> operator
> > as it is? I don't see its usefullness yet.
>
> guess you want to order something by "name" not by number which might be
> false in some cases (1,10,2,20,21 ... and so on).
>
> There it might be useful.
>
> Well i don think it is wrong behavior in that way.
>
> because having looping from a till z you wil get "aa" after z so that
> means aa is "higher" as z internally.
>
> but looping till "aa" dont brings out a-z like you get a-y when you loop
> till z (remember: for $i = a; $i <= z; $i++ gives the chars a-yz z right
> followed by "aa")
>
> Well if you implement something like that into a programming language it
> should at least have some kind of logic behavior. Don't you think?
>
That's okay, but not where my doubts are. I have not objections to the
comparison made alphabetically. What I doubt is the usefullness of
generating sequences with ++.
attached mail follows:
2006/6/6, Rasmus Lerdorf <rasmus
lerdorf.com>:
>
> Martin Alterisio wrote:
> > You're right about ++ operator not to be considered a math operator, my
> > mistake. What I should have said is that the usual connotation and
> expected
> > behaviour of ++ and the comparison operators is to give iteration
> > capabilities to a certain data type, as used in a for statement. For
> > that to
> > happen certain constrains must be true for these operators, one of them
> > being: any < ++any, which is not true for the way these operators behave
> in
> > php.
> >
> > I'm not saying "It's wrong let's change it right away!", I completely
> agree
> > that these rules can be bent on a not strongly typed language. The point
> > I'm
> > trying to make, the thing I want to understant without a trace of doubt,
> > is:
> > is it really worthy the functionality supplied with the string ++
> operator
> > as it is? I don't see its usefullness yet.
>
> It has been in PHP from the very beginning. So 10+ years. In that time
> it has been sparingly used, granted, but at the same time it really
> hasn't gotten in the way and removing it would break a number of legacy
> applications.
Well, that's enough reason to me, although a pain in the ass, backward
compatibility is an important issue. There will be plenty of opportunities
in future versions to revise this, for now my mind is at ease.
There were a lot more operators that worked on strings in the early
> days. '*' would do a cross-product, for example, treating the two
> string operands as vectors and returning a vector orthogonal to both of
> these. But I got tired of trying to explain to people what a cross
> product was and how strings mapped to vectors in Euclidean space and
> removed that. You could also at one point do "abc"-"b" to get "ac".
>
> -Rasmus
>
That's quite an anecdote, why isn't it somewhere in the php website or
manual? It's nice to know the humans behind the soft ^_^
That kind of operation might have been useful with arrays, as some other
operations to work with them as if they were sets (inclusion, union,
difference, etc). Yes, we have functions for that but apply a few of them
inside an if statement and I start to have LISP nightmares with all those
parenthesis.
attached mail follows:
On Tue, 2006-06-06 at 09:46, Martin Alterisio wrote:
> 2006/6/6, Robert Cummings <robert
interjinn.com>:
>
> > In C++ they do leave it to the coder, and well, we all know what a mess
> > it can be deciphering overloaded operators in C++ (or maybe we ALL
> > don't). At any rate, the PHP overlords made a choice, and IMHO the best
> > choice. For such a fringe issue I don't see what the argument is all
> > about. If you want the functionality you get in C by incrementing a
> > char, then use the chr() function on an integer.
> >
> >
> You're right about ++ operator not to be considered a math operator, my
> mistake. What I should have said is that the usual connotation and expected
> behaviour of ++ and the comparison operators is to give iteration
> capabilities to a certain data type, as used in a for statement. For that to
> happen certain constrains must be true for these operators, one of them
> being: any < ++any, which is not true for the way these operators behave in
> php.
You must have missed this post:
http://marc.theaimsgroup.com/?l=php-general&m=114945456908350&w=2
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Hello,
I just set up a test box for PHP/MySQL on a WinXP box and now I'm having
trouble with variables passed to browser from a link.
For example I have a link that outputs this:
http://localhost/index.php?team=CF10b. Now the CF10b cannot be user in the
code like it should.
I turned to Register Globals on in the php.ini but that didn't help. Any
ideas?
Thanks
-Will
attached mail follows:
Can you show us the script please?
"William Stokes" <kalles
operamail.com> wrote in message
news:16.B4.00946.ABF25844
pb1.pair.com...
> Hello,
>
> I just set up a test box for PHP/MySQL on a WinXP box and now I'm having
> trouble with variables passed to browser from a link.
>
> For example I have a link that outputs this:
> http://localhost/index.php?team=CF10b. Now the CF10b cannot be user in the
> code like it should.
>
> I turned to Register Globals on in the php.ini but that didn't help. Any
> ideas?
>
> Thanks
> -Will
>
attached mail follows:
On Tue, 6 Jun 2006 10:36:12 +0300, you wrote:
>I just set up a test box for PHP/MySQL on a WinXP box and now I'm having
>trouble with variables passed to browser from a link.
>
>For example I have a link that outputs this:
>http://localhost/index.php?team=CF10b. Now the CF10b cannot be user in the
>code like it should.
>
>I turned to Register Globals on in the php.ini but that didn't help. Any
>ideas?
Most likely you didn't turn RG on (typo? wrong php.ini?), or didn't
restart.
Try:
print_r ($_POST);
print_r ($_GET);
print_r ($_REQUEST);
to see if your variable is being passed. If it is, PHP isn't set up as
you want it. If it isn't, there's something more fundamental wrong.
--
http://www.otton.org/
attached mail follows:
Yess!
Wrong ini file...
There seems to be 3 of them on the same PC for some reason?
-W
"David Otton" <phpmail
jawbone.freeserve.co.uk> kirjoitti
viestissä:kefa82dmelcq9l5a2a99gtvihjhpcdd8co
4ax.com...
> On Tue, 6 Jun 2006 10:36:12 +0300, you wrote:
>
>>I just set up a test box for PHP/MySQL on a WinXP box and now I'm having
>>trouble with variables passed to browser from a link.
>>
>>For example I have a link that outputs this:
>>http://localhost/index.php?team=CF10b. Now the CF10b cannot be user in the
>>code like it should.
>>
>>I turned to Register Globals on in the php.ini but that didn't help. Any
>>ideas?
>
> Most likely you didn't turn RG on (typo? wrong php.ini?), or didn't
> restart.
>
> Try:
>
> print_r ($_POST);
> print_r ($_GET);
> print_r ($_REQUEST);
>
> to see if your variable is being passed. If it is, PHP isn't set up as
> you want it. If it isn't, there's something more fundamental wrong.
>
> --
>
> http://www.otton.org/
attached mail follows:
William Stokes wrote:
> Yess!
>
> Wrong ini file...
> There seems to be 3 of them on the same PC for some reason?
>
> -W
>
> "David Otton" <phpmail
jawbone.freeserve.co.uk> kirjoitti
> viestissä:kefa82dmelcq9l5a2a99gtvihjhpcdd8co
4ax.com...
>> On Tue, 6 Jun 2006 10:36:12 +0300, you wrote:
>>
>>> I just set up a test box for PHP/MySQL on a WinXP box and now I'm having
>>> trouble with variables passed to browser from a link.
>>>
>>> For example I have a link that outputs this:
>>> http://localhost/index.php?team=CF10b. Now the CF10b cannot be user in the
>>> code like it should.
>>>
>>> I turned to Register Globals on in the php.ini but that didn't help. Any
>>> ideas?
>> Most likely you didn't turn RG on (typo? wrong php.ini?), or didn't
>> restart.
>>
>> Try:
>>
>> print_r ($_POST);
>> print_r ($_GET);
>> print_r ($_REQUEST);
>>
>> to see if your variable is being passed. If it is, PHP isn't set up as
>> you want it. If it isn't, there's something more fundamental wrong.
>>
>> --
>>
>> http://www.otton.org/
Turn off register globals. Now. It is a HUGE security hole.
You do NOT need it turned on to use $_GET or the other superglobals, and
there is in fact no reason at all to EVER turn it on. The only
conceivable reason that someone would enable it is for an old badly
written script, and in that case one has to question why they are
running an old badly written script :)
Regards, Adam Zey.
attached mail follows:
Say I have a variable setting an ip address of 192.168.100.0
I want to be able to remove the last to chr's of that variable ie: .0
What would be my best solution to do that?
attached mail follows:
Tnx.
----- Original Message -----
From: "rich gray" <richgray
gmail.com>
To: "Rob W." <rob
fiberuplink.com>
Sent: Tuesday, June 06, 2006 2:44 AM
Subject: Re: [PHP] Removing an aspect of a variable...
> substr($variable,0,-2);
>
> Rob W. wrote:
>> Say I have a variable setting an ip address of 192.168.100.0
>>
>> I want to be able to remove the last to chr's of that variable ie: .0
>>
>> What would be my best solution to do that?
>>
>
>
>
attached mail follows:
But that will just give you .0. If you have 192.168.100.232 it will return
32. You have to check where the . is and then take the substring from that.
Use strpos or similar for that (I do not know if that can check backwards)
-----Original Message-----
From: Rob W. [mailto:rob
fiberuplink.com]
Sent: Tuesday, June 06, 2006 2:47 PM
To: richgray
gmail.com
Cc: php-general
lists.php.net
Subject: Re: [PHP] Removing an aspect of a variable...
Tnx.
----- Original Message -----
From: "rich gray" <richgray
gmail.com>
To: "Rob W." <rob
fiberuplink.com>
Sent: Tuesday, June 06, 2006 2:44 AM
Subject: Re: [PHP] Removing an aspect of a variable...
> substr($variable,0,-2);
>
> Rob W. wrote:
>> Say I have a variable setting an ip address of 192.168.100.0
>>
>> I want to be able to remove the last to chr's of that variable ie: .0
>>
>> What would be my best solution to do that?
>>
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
On 06/06/06, Rob W. <rob
fiberuplink.com> wrote:
> Say I have a variable setting an ip address of 192.168.100.0
>
> I want to be able to remove the last to chr's of that variable ie: .0
>
> What would be my best solution to do that?
>
Remove the last two characters of a string?
$shorterString = substr($string, 0, -2);
Whether that's really what you want to be doing with an IP address is up to you.
-robin
attached mail follows:
At 12:37 AM 6/6/2006, Rob W. wrote:
>Say I have a variable setting an ip address of 192.168.100.0
>
>I want to be able to remove the last to chr's of that variable ie: .0
>
>What would be my best solution to do that?
If you want the last two characters you can use substr():
[1] $sResult = substr($sIP, -2);
If you want the string from the last period onward, regardless of
length, you can use strrpos() and substr():
[2] $iPos = strrpos($sIP, ".");
if ($iPos !== FALSE) $sResult = substr($sIP, -$iPos);
Take the time to read about various string functions -- you'll thank yourself.
http://php.net/strings
Paul
[1] substr
http://php.net/substr
see Example 2. Using a negative start
[2] strrpos
http://php.net/strrpos
attached mail follows:
On Tue, 6 Jun 2006 08:52:46 +0100, Robin Vickery wrote:
>On 06/06/06, Rob W. <rob
fiberuplink.com> wrote:
>> Say I have a variable setting an ip address of 192.168.100.0
>>
>> I want to be able to remove the last to chr's of that variable ie: .0
>>
>> What would be my best solution to do that?
>>
>
>Remove the last two characters of a string?
>
> $shorterString = substr($string, 0, -2);
>
>Whether that's really what you want to be doing with an IP address is up to you.
substr will remove the last two characters from a string, as mentioned
above.
If you want to remove the last byte from an IP address (which could be
.0, .10, or .100) I would suggest:
$ip = "192.168.100.0";
$ip = explode ('.', $ip);
array_pop ($ip);
$ip = implode ('.', $ip);
With PHP 5.1 and up, explode accepts a negative limit, which would
simplify things.
--
http://www.otton.org/
attached mail follows:
Well.... Do you have folder called tmp in your root?????
ThePanister!
"Tom" <tomasjliendo
hotmail.com> wrote in message
news:7F.D2.00946.B2384844
pb1.pair.com...
> Does some well-known problem exist with the session variables in Windows
> servers?
> Because in a system that I have running on a Windows server, sometimes the
> session variables are null causing errors, then I close the browser and
open
> it and in the next intent everything works well... I can't understand
why...
> The same system in a Linux server runs well always ¿?
>
> Ahead of time, thank you very much,
>
> Tom.
attached mail follows:
Dave M G wrote:
> Chris,
>
> Thank you for replying.
>>> $object = new $className();
>>> Is this possible?
>> If in doubt, test it out ;)
>> Yes, it will work.
> Oh, that's actually the code I can use? I just wrote it as an
> explanatory aid, not thinking that it could be literally done like that.
> I assumed there was a specific command I was missing.
>
> Well, anyway, I guess I've stumbled on the right syntax. Thank you for
> pointing it out to me.
also check out call_user_func() and call_user_func_array() - you might
find them handy in certain situations.
>
> --
> Dave M G
>
attached mail follows:
Hi,
Im having a trouble using memcached with pear db.
When im using memcache to store and retrieve an string, all works fine.
When Im using memcache to store a pear db resulset, it does not work!!
This retrieves data but pear::db does not understand it.
I really dont know
Any ideas?
Thanks in advance
Code:
$sql = "SELECT * FROM anytable";
$myownqry= cachedSQL($sql);
while ($rs_qryPhoto =& $myownqry->fetchRow()) {
echo "OK<bR>"; //When variable is taken from cache, nothink is
shown!!!
}
$MEMCACHE_CONNECTED=0;
$MEMCACHE_STR="";
function memcachedConnect(){
global $MEMCACHE_CONNECTED,$MEMCACHE_STR;
if(!($MEMCACHE_CONNECTED)){
$MEMCACHE_CONNECTED=1;
$MEMCACHE_STR = memcache_connect('192.168.2.8', 11211);
}
}
function cachedSQL($sSQL) {
global $db,$MEMCACHE_CONNECTED,$MEMCACHE_STR;
memcachedConnect();
if($tmp=memcache_get($MEMCACHE_STR,MD5($sSQL))){
echo "Cached<br>";
//echo var_dump($tmp);
}else{
$tmp = $db->query($sSQL);
//echo var_dump($tmp);
echo "<b>NOT</b> Cached<br>";
memcache_set($MEMCACHE_STR, MD5($sSQL), $tmp, 0, 10);
}
echo "<br><br>";
return $tmp;
}
attached mail follows:
On 6/6/06 9:55 AM, Ruben Rubio Rey wrote:
> Im having a trouble using memcached with pear db.
>
> When im using memcache to store and retrieve an string, all works fine.
> When Im using memcache to store a pear db resulset, it does not work!!
>
> This retrieves data but pear::db does not understand it.
> I really dont know
This is because $db->query returns a resource, which is a reference to
the data and not the data itself.
For example, let's say you're using the MySQL driver for PEAR::DB, then
when you call $db->query(), it uses mysql_query(). This function will
return a resource. When you store the resource to the memcache server
and then later retrieve it, it no longer maintains its reference to the
data.
If you want to store the data to the cache, I suggest you use getAll()
to retrieve an array of data and then store that to the memcache server:
$db->setFetchMode(DB_FETCHMODE_ASSOC);
$data =& $db->getAll($sSQL);
memcache_set($MEMCACHE_STR, MD5($sSQL), $data, 0, 10);
Now, your result set is stored properly on the memcache server.
--
Ben Ramsey
http://benramsey.com/
attached mail follows:
Ben Ramsey wrote:
> On 6/6/06 9:55 AM, Ruben Rubio Rey wrote:
>
>> Im having a trouble using memcached with pear db.
>>
>> When im using memcache to store and retrieve an string, all works fine.
>> When Im using memcache to store a pear db resulset, it does not work!!
>>
>> This retrieves data but pear::db does not understand it.
>> I really dont know
>
>
> This is because $db->query returns a resource, which is a reference to
> the data and not the data itself.
>
> For example, let's say you're using the MySQL driver for PEAR::DB,
> then when you call $db->query(), it uses mysql_query(). This function
> will return a resource. When you store the resource to the memcache
> server and then later retrieve it, it no longer maintains its
> reference to the data.
>
> If you want to store the data to the cache, I suggest you use getAll()
> to retrieve an array of data and then store that to the memcache server:
>
> $db->setFetchMode(DB_FETCHMODE_ASSOC);
> $data =& $db->getAll($sSQL);
> memcache_set($MEMCACHE_STR, MD5($sSQL), $data, 0, 10);
>
> Now, your result set is stored properly on the memcache server.
>
Yes, it has sense. I have been working arround it but I didn't found the
solution. I ll try it tomorrow I ll tell what has happen!!!
Thanks a lot men!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]