php-general Digest 14 Oct 2006 20:25:45 -0000 Issue 4401

Topics (messages 243123 through 243147):

Re: OOP slow -- am I an idiot?
        243123 by: Tony Marston
        243124 by: Tony Marston
        243125 by: Tony Marston
        243126 by: Tony Marston

Re: Windows ENV['_'] equivalent
        243127 by: Stut
        243144 by: Ed Lazor

Class returning more than one value
        243128 by: Deckard
        243129 by: Paul Scott

Re: PHP Denial of service
        243130 by: Ryan Barclay
        243131 by: Ryan Barclay
        243132 by: Ryan Barclay
        243133 by: Roman Neuhauser
        243146 by: Ed Lazor

Crossing over to the Darkside?
        243134 by: Ross
        243135 by: Roman Neuhauser
        243136 by: Roman Neuhauser
        243145 by: Rory Browne
        243147 by: Ed Lazor

Retrieving values from array on a class
        243137 by: AR
        243138 by: Roman Neuhauser
        243139 by: AR
        243140 by: Roman Neuhauser
        243141 by: AR
        243142 by: Roman Neuhauser

Re: A no brainer...
        243143 by: Ed Lazor

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
"Stut" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Tony Marston wrote:
>> "Stut" <[EMAIL PROTECTED]> wrote in message 
>> news:[EMAIL PROTECTED]
>>
>>> My general approach to designing a system is data-centric. I tend to 
>>> start by defining the database schema since getting that clear in my 
>>> head tends to lead me to a decent design.
>>>
>>
>> What a coincidence! That's exactly my approach, but I've taken it one 
>> step further. I always start with a properly normalised database which I 
>> can then import into my daa dictionary application. From there I can 
>> press a button and create a class file for each database table, and I am 
>> ptting the finishing touhes to a procedure whereby I can press another 
>> button to generate the scripts which will maintain each table. This means 
>> I can get basic transactions up and running without writing a single line 
>> of code. All I have to do is edit these files to include business logic 
>> and any customisations.
>>
>> This level of automation is not possible with some people's OO 
>> implementations, so I can only conclude that their approach is not the 
>> optimal one.
>>
>
> Youch!! Your implementation seems to be focused on development efficiency 
> rather than runtime efficience.

Precisely. That is why I said it was adminstrative web applications which 
typically have far fewer users than web sites.

> In all but rare research projects this is backwards for a web-based 
> system.

Wrong again. This is for administrative web applications, the type that were 
previously built as desktop applications. Their function is to get data into 
and out of a database i.e. CRUD applications), not to serve thousands of 
casual vuisitors.

> This is exactly the practice I am trying to discourage. It's a well-known 
> fact that code generators are a poor substitute for real developers.

It depends how you go about it. My code generators fulfil the basics, then 
the programmer's job is to customise it.

>>> For most projects I don't start out with OOP in mind, but my brain is 
>>> used to building OOP-style systems so nearly everything I do ends up 
>>> with a few classes.
>>>
>>
>> The difference with me is that I don't waste my time with trivial 
>> websites, I concentrate on administrative web applications. But even when 
>> I wrote the code for my own website at http://www.radicore.org I still 
>> used all my database classes as it was far easier than doing it the 
>> traditional old-fashioned way
>
> Trivial websites are where you can get away with using code generators. 
> For anything non-trivial I would not feel comfortable with a 
> jack-of-all-trades-master-of-none-style of code. Now that I think of it 
> I'm quite anal about the quality of my code, so I don't think I'd ever use 
> a code generator - never have before.

I have never liked any of the code generators I have seen created by others, 
but with my general-purpose framework I noticed that a lot of the code that 
I was generating by hand followed a familiar pattern. It was then a simple 
exercise to write a program to generate this same code on command.

Be aware that I am not attempting to generate *all* the code that an 
application will need, just the basics to  get it functioning. This takes 
all the drudgery out of the job and leaves the programmer to do the 
interesting bits.

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

--- End Message ---
--- Begin Message ---
"Stut" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Ed Lazor wrote:
>> On Oct 12, 2006, at 4:36 PM, Stut wrote:
>>> If I then go on to create an admin interface for the users, I would 
>>> create another completely separate class called UserCollection to handle 
>>> more than one user. I may at that point choose to expose any 
>>> data-massaging methods in User to UserCollection to avoid code 
>>> duplication, but that would be the extent of the way UserCollection uses 
>>> the User class since the User class is optimised to work on a single 
>>> user at any one time.
>>
>> We use a similar approach for the user class.  I haven't ever implemented 
>> something like the UserCollection class though.  I'm curious about that. 
>> Does your UserCollection class extend the basic user class?  Or is it 
>> something else entirely; I dunno, maybe UserCollection has a property 
>> defined as an array of User class?  I think that's what people were 
>> saying earlier in the thread as being a "very bad thing" in terms of 
>> memory utilization, etc.
>
> Indeed, that would be a very bad thing, unless you've already considered 
> that. I've previously mentioned that I have an ActiveRecord-style 
> implementation for a lot of my DB access. The base class for that system 
> has a static function called FindAll which will return an array of 
> objects. However, it only does a single SQL statement. The base class also 
> has a method LoadFromArray which, shockingly, loads the object from an 
> array. This means that from a single DB request I can get an array of 
> objects each representing one entitity (potentially a row, but not 
> necessarily).

The very idea of one object per row makes me want to throw up. I have one 
object per table, and each object can deal with any number of rows. I don't 
use getters and setters to access the columns from any row, I simply input 
an array (typically one row from the $_POST array) and output an array which 
may contain any number of rows. I find this to be far easier and no less 
efficient.

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

--- End Message ---
--- Begin Message ---
"Ed Lazor" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> On Oct 13, 2006, at 1:35 AM, Tony Marston wrote:
>> What a coincidence! That's exactly my approach, but I've taken it  one 
>> step
>> further. I always start with a properly normalised database which I  can 
>> then
>> import into my daa dictionary application. From there I can press a 
>> button
>> and create a class file for each database table, and I am ptting the
>> finishing touhes to a procedure whereby I can press another button to
>> generate the scripts which will maintain each table. This means I  can 
>> get
>> basic transactions up and running without writing a single line of  code. 
>> All
>> I have to do is edit these files to include business logic and any
>> customisations.
>
> Is the Radicore framework still available?

What do you mean *still*? Since I released it I have never closed it down. I 
am still working on it and releasing improvements. I am just about to 
release some new functionality which will generate more standard code for 
each transaction. Watch my website (see link in my signature) for an 
announcement.

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

--- End Message ---
--- Begin Message ---
"Ed Lazor" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> On Oct 13, 2006, at 1:54 AM, Stut wrote:
>> Youch!! Your implementation seems to be focused on development 
>> efficiency rather than runtime efficience. In all but rare research 
>> projects this is backwards for a web-based system. This is exactly  the 
>> practice I am trying to discourage. It's a well-known fact that  code 
>> generators are a poor substitute for real developers.
>
> I agree with Stut, but I'd also like to check out a copy of the 
> framework.  It seems like a lot of people are using frameworks now  days 
> and I can't help but wonder if they provide similar performance  as the 
> OOP library that Stut uses.

If you want to build administrative web applications which have a small 
number of users, and where development costs are more important than 
performance of execution (i.e. developer cycles over cpu cycles) then check 
out RADICORE at http://www.radicore.org It is better than Ruby on Rails.

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

--- End Message ---
--- Begin Message ---
Ed Lazor wrote:
On Oct 13, 2006, at 11:53 AM, Richard Lynch wrote:
In windows...  There ain't nothing in phpinfo() that matches the
php.exe which I'm running...

How do you handle this?

Not a solution, but an idea... the dos chdir comand. Maybe you can run it from within your script. It tells you the current working directory and you end up indirectly knowing the location of the php.exe that you're using.

Unfortunately there's no guarantee that a) the working directory will be where the PHP binary is, or b) that the binary is called php.exe.

Richard: AFAIK there is no way to know this under windows without writing an extension to tell you.

-Stut

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

On Oct 14, 2006, at 2:09 AM, Stut wrote:

Unfortunately there's no guarantee that a) the working directory will be where the PHP binary is, or b) that the binary is called php.exe.

Richard: AFAIK there is no way to know this under windows without writing an extension to tell you.

-Stut

Wouldn't it be an easy task of PHP checking the results to see if file_exists? That would resolve the first part, but it might indirectly tell you whether you're using php.exe. If the file_exists fails, then you can probably assume you're using the dll. I know... a hacked solution, but maybe it will work?

-Ed

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

How can i code a class with a function that returns more than one value ?

Any help would be appreciated.

Warm Regards,
Deckard

--- End Message ---
--- Begin Message ---
On Sat, 2006-10-14 at 11:06 +0100, Deckard wrote:
> How can i code a class with a function that returns more than one value ?
> 

1. return array();
2. return stdClass;

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 

--- End Message ---
--- Begin Message ---
I have just run a phpinfo and ignore_user_abort is indeed defaulting to off.

It's a pretty heavy php-MySQL script. I noticed on scripts without the MySQL interaction, the server can keep up much better with the forced refreshes.
Are there any other liming settings I can change?

All the best,

Ryan

--
Ryan Barclay

RBFTP Networks Ltd.

DDI: +44 (0)870 490 1870
WWW: http://www.rbftpnetworks.com
BBS: http://forums.rbftpnetworks.com



Robert Cummings wrote:
On Sat, 2006-10-14 at 01:25 +0100, Ryan Barclay wrote:
Robert,

Thanks for the reply. I can't seem to find ignore_user_abort in my php.ini. I would like to do it at server level, rather than individual scripts. Do you know roughly where is it? I think there were some versions with this missing in the ini, which was later fixed.

I'm guessing that if ignore_user_abort is set to on, this could be the culprit?

Would simply adding the following to the ini work?:

ignore_user_abort = off

If it's not in your php.ini and not in your source code then it's
already off, unless it's being activated by an http.conf or .htaccess
setting. The default for ignore_user_abort is 0.

What exactly does your script do? It may be possible that whatever task
it is performing prevents PHP from immediately recognizing the user
abort and subsequently terminating.

Cheers,
Rob.

--- End Message ---
--- Begin Message ---
Jon,

Thanks for the reply. Yes, ignore_abort is defaulting to off, as stated in my other post. We have a Firebox III 1000 firewall on our external, however this does not have any features like this. I will look into iptables.

Thanks,

Ryan

--
Ryan Barclay

RBFTP Networks Ltd.

DDI: +44 (0)870 490 1870
WWW: http://www.rbftpnetworks.com
BBS: http://forums.rbftpnetworks.com



Jon Anderson wrote:
Ryan Barclay wrote:
Thanks for the reply. I can't seem to find ignore_user_abort in my php.ini. I would like to do it at server level, rather than individual scripts. Do you know roughly where is it? I think there were some versions with this missing in the ini, which was later fixed.

I'm guessing that if ignore_user_abort is set to on, this could be the culprit?

Would simply adding the following to the ini work?
Ignore user abort defaults to off, and doesn't necessarily help you if the clients don't terminate their connections properly, or they're actually trying to DoS you. I think your best bet is to either use some lightweight detection in PHP (and maybe send an HTTP error header if you're getting hit), or better yet, use a firewall if one is available to prevent the connections from even getting to your webserver and wasting its resources. (If your server is running on Linux, iptables should be able to do what you need, and there are more complicated solutions too.)

jon

--- End Message ---
--- Begin Message --- It hasn't actually been attempted. However, if a couple of a users were to hold the refresh, the page generation times would go up ridiculously and clients would be waiting over 20sec for pages. As mentioned, it's a very heavy php-mysql script with lots of queries.

Ryan

--
Ryan Barclay

RBFTP Networks Ltd.

DDI: +44 (0)870 490 1870
WWW: http://www.rbftpnetworks.com
BBS: http://forums.rbftpnetworks.com



Ed Lazor wrote:

On Oct 13, 2006, at 2:16 PM, Ryan Barclay wrote:

A simple question I imagine, but I am wondering how I would combat DoS attacks by users holding the REFRESH key on their browsers?

I have reproduced this error on a PHP-MYSQL website and when I hold the REFRESH key on for a while, page gen times shoot up dramatically and hundreds of processes are created.

Is there a way I can stop this/limit the connections/processes in apache conf/php.ini?

Apache.conf ThreadsPerChild?

What can I do to combat this method of DoS?

How do you consider this a DoS attack? Are you seeing servers crippled because a user or a couple of users keep hitting the refresh key? Honestly, it seems extreme. Your server should be able to handle much higher loads than that, especially when PHP starts caching pages, etc.. I would start double checking the server config, etc..

Also, if you're really worried about someone "attacking" a site like this, you could just take advantage of PHP's auto_prepend to automatically log the IP and a time stamp of each page request... and if the last page request is within N seconds of the current request, you just redirect the user to a page that says something like "server busy, try again in a moment".

-Ed



--- End Message ---
--- Begin Message ---
# [EMAIL PROTECTED] / 2006-10-13 22:16:18 +0100:
> A simple question I imagine, but I am wondering how I would combat DoS 
> attacks by users holding the REFRESH key on their browsers?
> 
> I have reproduced this error on a PHP-MYSQL website and when I hold the 
> REFRESH key on for a while, page gen times shoot up dramatically and 
> hundreds of processes are created.
> 
> Is there a way I can stop this/limit the connections/processes in apache 
> conf/php.ini?
> 
> What can I do to combat this method of DoS?

    I haven't tried it, but perhaps this would work:

    apache-1.3: http://dominia.org/djao/limitipconn.html
    apache-2.0: http://dominia.org/djao/limitipconn2.html

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

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

On Oct 14, 2006, at 4:05 AM, Ryan Barclay wrote:

It hasn't actually been attempted. However, if a couple of a users were to hold the refresh, the page generation times would go up ridiculously and clients would be waiting over 20sec for pages. As mentioned, it's a very heavy php-mysql script with lots of queries.

I see what you're talking about. Does everyone need live data for each page request? It seems like a great opportunity for data / page caching. I'm trying to remember the name of the caching tool I used, but I ran into something similar on one of my websites a few years ago. Each page was dynamic and the server load was high. I installed caching and pages would only update occasionally... meaning that users received pages from the cache, instead of each page getting processed with each request. You could also try a reverse proxy with apache to do something similar. The limit IP stuff from Roman also looks interesting.

-Ed

--- End Message ---
--- Begin Message ---
Hello,

Having used php for a while now and am fairly competent I was persuaded by a 
collegue to look into asp.net.  I decided to download the free trial of 
VS2005 and start with a few tutorials.

I am very suprised how easy  things like user auhtentication and form 
validation is. Literally in minutes. Even though I have written a similar 
script many times for php there is always some tweeking or modifying 
required before it fits the project. The asp object model is far superior, 
something that PHP developers can't really argue against.

Now I know asp .net is not ideal for all projects but I am now thinking that 
there are some projects that would be suited to the use of .net and the 
development time would be greatly reduced. I would like to know


-What is planned for the next version of PHP?
-How many of  you use both of the technologies?
-What influences your decision when using either ASP, .NET, or PHP


I know people feel very strongly about PHP, however I don't want to start an 
argument, just want a decent discussion,


Regards,


R.

--- End Message ---
--- Begin Message ---
# [EMAIL PROTECTED] / 2006-10-14 13:52:50 +0100:
> Having used php for a while now and am fairly competent I was persuaded by a 
> collegue to look into asp.net.  I decided to download the free trial of 
> VS2005 and start with a few tutorials.
> 
> I am very suprised how easy  things like user auhtentication and form 
> validation is. Literally in minutes. Even though I have written a similar 
> script many times for php there is always some tweeking or modifying 
> required before it fits the project.
>
> The asp object model is far superior, 

    That's a comparision of code you wrote in PHP with code Microsoft
    programmers wrote in C#, and has nothing to do with PHP.
    
> something that PHP developers can't really argue against.

    It's hard to say either way since you didn't show us your code.

    Are you aware that you're comparing libraries, not programming
    languages?  There's a gazillion authentication libraries written
    in PHP to choose from if you can't write one yourself.
 
> Now I know asp .net is not ideal for all projects but I am now
> thinking that there are some projects that would be suited to the use
> of .net and the development time would be greatly reduced.

    Well, libraries boost development.

> I would like to know
> 
> -What is planned for the next version of PHP?
> -How many of  you use both of the technologies?
> -What influences your decision when using either ASP, .NET, or PHP

    License.
 
-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

--- End Message ---
--- Begin Message ---
# [EMAIL PROTECTED] / 2006-10-14 16:53:34 +0000:
> # [EMAIL PROTECTED] / 2006-10-14 13:52:50 +0100:
> > -What influences your decision when using either ASP, .NET, or PHP
> 
>     License.

    Scratch that, TCO is it. License is a mere contributor to TCO.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

--- End Message ---
--- Begin Message ---
On 10/14/06, Ross <[EMAIL PROTECTED]> wrote:

Hello,

Having used php for a while now and am fairly competent I was persuaded by
a
collegue to look into asp.net.  I decided to download the free trial of
VS2005 and start with a few tutorials.

I am very suprised how easy  things like user auhtentication and form
validation is. Literally in minutes. Even though I have written a similar
script many times for php there is always some tweeking or modifying
required before it fits the project. The asp object model is far superior,
something that PHP developers can't really argue against.


That's a bit like saying that apples are better than oranges. PHP and
ASP.NET, while they were designed to server similar, but not identical
purposes, are different tools. PHP is a programming language, but ASP.NET is
a platform, built on the dotNET framework. You could compare something like
CakePHP to ASP.NET, in pretty much the same way as you could compare PHP
itself to C#.


Now I know asp .net is not ideal for all projects but I am now thinking that
there are some projects that would be suited to the use of .net and the
development time would be greatly reduced. I would like to know


Unless dotNET is a total absolute piece of crap, them I'm sure there are
some things that are better suited to the ASP.NET than to their PHP
counterpart. I suspect this would be mainly things that integrate with other
MS technologies.


-What is planned for the next version of PHP?

Google is good for you.
http://www.corephp.co.uk/archives/19-Prepare-for-PHP-6.html

-How many of  you use both of the technologies?
-What influences your decision when using either ASP, .NET, or PHP


The first thing it would depend on would be whether I wanted a framework or
a programming language. If I wanted a framework I'd go with ( out of the
above choices ) ASP.NET, where as if I wanted a programming language I'd go
for PHP. Given the choice however, I'd go with a PHP based framework for
websites, unless they had to integrate with windos services.

I don't currently know ASP.NET enough to use it for production purposes,
added to the fact that most of our machines are Solaris, and not Windos.

I know people feel very strongly about PHP, however I don't want to start an
argument, just want a decent discussion,


You serious? I would never have thought people on the PHP mailing list would
have any interest at all on PHP.

--- End Message ---
--- Begin Message --- I agree with Roman and Rory's comments, but I figure I might be able to add something, so here goes...

On Oct 14, 2006, at 5:52 AM, Ross wrote:

I am very suprised how easy  things like user auhtentication and form
validation is. Literally in minutes. Even though I have written a similar
script many times for php there is always some tweeking or modifying
required before it fits the project.

Checkout :
        - Zend Studio
        - Zend Platform
        - Zend Framework
        - Dreamweaver

Google search:
        - "PHP Framework"
        - "PHP library"

Also checkout Ruby on Rails. Last, but not least, search the PHP mailing list for other available PHP frameworks for leads.

Keep in mind that editors may save you some work, but they often use a generic approach - bloated code, less efficient code, code that doesn't meet the specific needs of your project, code that's difficult to change without fighting the editor, and code that's more difficult to troubleshoot when you run into problems. Some people are actually faster when coding manually, but that applies to C# just as much as it does to PHP.

The asp object model is far superior,
something that PHP developers can't really argue against.

On what basis are you saying one is superior? It sounds like you're still trying to learn the differences between your options in order to choose which one to focus on. Please list individual reasons for the superiority that you're talking about and give people a chance to provide counter arguments or counter examples. Every language, development platform, and development library has strengths and weaknesses.

Now I know asp .net is not ideal for all projects but I am now thinking that there are some projects that would be suited to the use of .net and the
development time would be greatly reduced.

Sure, but the same thing could be said for PHP and some of it's available development tools.

I would like to know


-What is planned for the next version of PHP?

In case you're not already checking, you'll have a more balanced comparison if you also find out what's planned for the next version of ASP or .NET.

-How many of  you use both of the technologies?

I do. It's more expensive. There's a lot more work in applying updates. There's also a lot more work to stay current with changes in technology; Jack of all trades, master of none.

-What influences your decision when using either ASP, .NET, or PHP

The individual needs of each project. It's usually best to stick with whatever the customer is using if they already have a large investment in a particular technology. However, it is sometimes cost effective to switch if the customer can afford it - Google "PHP versus ASP" or "PHP versus .NET" for plenty of examples. Google "Linux versus Windows"; this ties into the debate. Compare the cost of hiring developers for each of the technologies. Compare the cost of hosting on Linux versus hosting on Windows. Compare the security of IIS versus Apache. And, like someone else mentioned, compare your value in being able to develop on one platform versus your value in being able to develop for one server platform versus your value in being able to develop for all of the server platforms that Apache/PHP work under. I've seen examples of .NET being implemented under UNIX; they didn't work all that well from what I saw, but researching this might also add to your pool of knowledge on which direction to go.

-Ed

--- End Message ---
--- Begin Message ---
Hello,

Sorry for the newbie question :(

I have this class named "returnConfigParams" that returns an array
called "$values" through a function called "getMySQLParams()".

My question is how to retrieve the values of the array from the file
that calls the class.

I have:

$params_file = New returnConfigParams;
$params_file->getMySQLParams();
print($params_file[0]);

but doesn't work :(

Help me please.

I'm stuck on this for two hours and didn't find nothing on Google that
could help me.

Cheers,
AR

--- End Message ---
--- Begin Message ---
# [EMAIL PROTECTED] / 2006-10-14 15:55:57 +0100:
> Hello,
> 
> Sorry for the newbie question :(
> 
> I have this class named "returnConfigParams" that returns an array
> called "$values" through a function called "getMySQLParams()".
> 
> My question is how to retrieve the values of the array from the file
> that calls the class.
> 
> I have:
> 
> $params_file = New returnConfigParams;
> $params_file->getMySQLParams();
> print($params_file[0]);

var_dump($params_file->getMySQLParams());

You said the method returns the data, right?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

--- End Message ---
--- Begin Message ---
Hello,

>> I have this class named "returnConfigParams" that returns an array
>> called "$values" through a function called "getMySQLParams()".
>>
>> My question is how to retrieve the values of the array from the file
>> that calls the class.
>>
>> I have:
>>
>> $params_file = New returnConfigParams;
>> $params_file->getMySQLParams();
>> print($params_file[0]);
> 
> var_dump($params_file->getMySQLParams());
> 
> You said the method returns the data, right?
Yes, it returns an array called $values.
My problem is how to access the individual member of the array.

Thanks in advance.

Cheers,
AR

--- End Message ---
--- Begin Message ---
# [EMAIL PROTECTED] / 2006-10-14 16:28:57 +0100:
> Hello,
> 
> >> I have this class named "returnConfigParams" that returns an array
> >> called "$values" through a function called "getMySQLParams()".
> >>
> >> My question is how to retrieve the values of the array from the file
> >> that calls the class.
> >>
> >> I have:
> >>
> >> $params_file = New returnConfigParams;
> >> $params_file->getMySQLParams();
> >> print($params_file[0]);
> > 
> > var_dump($params_file->getMySQLParams());
> > 
> > You said the method returns the data, right?
> Yes, it returns an array called $values.
> My problem is how to access the individual member of the array.

    Just like you'd access members of any other array.

    $whatever = $params_file->getMySQLParams();
    print($whatever[0]);

    This is a matter of basic rules of the language. Did you know
    most of the grammer is described in the manual?

    http://www.php.net/manual/en/langref.php 

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

--- End Message ---
--- Begin Message ---
Hello,

>     Just like you'd access members of any other array.
> 
>     $whatever = $params_file->getMySQLParams();
>     print($whatever[0]);
> 
>     This is a matter of basic rules of the language. Did you know
>     most of the grammer is described in the manual?
Sure, i already tried that, but it doesn't works.
All i get is a blank page.

BTW, here is my class:

class returnConfigParams
 {

  var $a;
  var $b;
  var $c;
  var $d;
        

  function getMySQLParams()
   {
    include($_SERVER['DOCUMENT_ROOT']."/properties.php");
        
    $values = array(0 => $a, 1 => $b, 2 => $c, 3 => $d);
        
    return($values);

  }

}

Cheers,
AR

--- End Message ---
--- Begin Message ---
# [EMAIL PROTECTED] / 2006-10-14 16:42:37 +0100:
> >     Just like you'd access members of any other array.
> > 
> >     $whatever = $params_file->getMySQLParams();
> >     print($whatever[0]);
> > 
> >     This is a matter of basic rules of the language. Did you know
> >     most of the grammer is described in the manual?

> Sure, i already tried that, but it doesn't works.
> All i get is a blank page.
> 
> BTW, here is my class:
> 
> class returnConfigParams
>  {
> 
>   var $a;
>   var $b;
>   var $c;
>   var $d;
>       
> 
>   function getMySQLParams()
>    {
>     include($_SERVER['DOCUMENT_ROOT']."/properties.php");
>       
>     $values = array(0 => $a, 1 => $b, 2 => $c, 3 => $d);
>       
>     return($values);
> 
>   }
> 
> }

    since you don't say what's in the included file, I'll assume
    it's empty. $a will be unset and print($rCP->getMySQLParams())
    will print nothing ("").

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

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

Of course, the cost of serialization and deserialization is non- trivial for any data structure that is of interesting size, and you have to keep in mind that if you aren't syncing to the database periodically then you will end up with stale data objects. (An issue in any case, but the longer the object
representing a view of your database exists, the more of a problem it
becomes.  YMMV depending on the data you're holding.)

Has anyone done tests on the difference between the value and performance of serializing data structures versus just pulling the data from the database?

PHP stores session data in files by default. There's gotta be a performance hit for the file access. If you store session data in MySQL, you're still making a DB query. It seems to me that the performance is almost the same, which means grabbing the current record ends up better because you avoid stale data. What do you think?

-Ed

--- End Message ---

Reply via email to