Re: [PHP] private properties problem

2005-10-21 Thread Colin Shreffler
I'm not sure this is a problem.  I ran the same test and as you say, it
dynamically created a new variable with local scope to the derived (child)
class.  I would expect this to happen as it can not access private members
of its base (parent) class.

In your statement:

"But when trying to access this value from the parent class, it is not
there."

Well it shouldn't be.  A base class does not know anything about its
derived class's members or methods.  Inheritence doesn't work in that
direction.  Only derived classes know about their base class members or
methods.

-c


> Today I discovered a possible serious problem with the way the latest
> PHP versions handle private properties.
>
> Given the following code:
>
> 
> class Base
> {
> private $var1 = 0;
> }
>
> class FinalClass extends Base
> {
>
> function Test()
> {
> $this->var1 = 10;
> }
> }
>
> $c = new FinalClass();
>
> $c->Test();
>
> print_r( $c );
>
> ?>
>
>
> I get the following result:
>
> FinalClass Object
> (
> [var1:private] => 0
> [var1] => 10
> )
>
>
> Now... PHP should have displayed an error when I was trying to set a
> value to this private member from the parent class. No error message was
> displayed. It created a local member which holded the value 10. But when
> trying to access this value from the parent class, it is not there.
>
> I think PHP should notify of the problem but it is not doing so. I have
> my error reporting level on E_ALL.
>
> Any ideas?
>
> Pablo Godel
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>


Thank you,
Colin Shreffler
Principal
303.349.9010 - cell
928.396.1099 - fax
[EMAIL PROTECTED]

Warp 9 Software, LLC.
6791 Halifax Avenue
Castle Rock, CO 80104

Confidentiality Notice: The information in this e-mail may be confidential
and/or privileged. This e-mail is intended to be reviewed by only the
individual or organization named in the e-mail address. If you are not the
intended recipient, you are hereby notified that any review, dissemination
or copying of this e-mail and attachments, if any, or the information
contained herein, is strictly prohibited.

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



[PHP] Calling PostgreSQL & MySQL Stored Procedures

2005-10-22 Thread Colin Shreffler
Can any one please tell me how you call a stored procedure in either
PostgreSQL or MySQL from php?

Cheers
-c


Re: [PHP] Calling PostgreSQL & MySQL Stored Procedures

2005-10-22 Thread Colin Shreffler
One more caveat:  With an without parameters would be very helpful.

-c


On 10/22/05 11:55 AM, "Colin Shreffler" <[EMAIL PROTECTED]>
wrote:

> Can any one please tell me how you call a stored procedure in either
> PostgreSQL or MySQL from php?
> 
> Cheers
> -c


Thank you,
Colin Shreffler
Principal
303.349.9010 - cell
[EMAIL PROTECTED]

Warp 9 Software, LLC.
6791 Halifax Avenue
Castle Rock, CO 80104

Confidentiality Notice: The information in this e-mail may be confidential
and/or privileged. This e-mail is intended to be reviewed by only the
individual or organization named in the e-mail address. If you are not the
intended recipient, you are hereby notified that any review, dissemination
or copying of this e-mail and attachments, if any, or the information
contained herein, is strictly prohibited.

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



Re: [PHP] Abstract Classes?

2005-10-23 Thread Colin Shreffler
One reason would be that you might not know the details of a derived class's
implementation details at design time.

For instance I could have an abstract class such as this:

Class MyTestClass
{
function doSomething()
{
doSomethingElse();
}

abstract function doSomethingElse() ;
}

As you can see I have an abstract function with no details.  I know that
when the doSomething() function is called it must call the doSomethingElse
Function, but at the time that I define MyTestClass I don't know what that
is exactly.

Now say another developer needs to derive a class from MyTestClass.  Because
the base class is abstract they must define an emplementation for the
doSomethingElse class such as:

Class MyDerivedClass extends MyTestClass
{
function doSomethingElse()
{
// here the developer must specify the specifics of what this method
does
}
}

Now in our business logic if we do the following:

$myClass = new MyDerivedClass();
$myClass->doSomething();

The code will actually execute the doSomethingElse()  implementation that
has been defined in MyDerivedClass.

This can be extremely useful in developing frameworks that you want other
developers to extend on their own and also in business systems where you
might need to maintain a system by adding new classes/implementations over
time.  Certain patterns also make heavy uses of interfaces and abstract
classes.

Perhaps a real-world example would make more sense.  Does this help?  If
not, let me know and I'll come up with a similar/real-world example.

Colin

On 10/23/05 4:40 AM, "Alan Lord" <[EMAIL PROTECTED]> wrote:

> Thanks Jasper,
> 
> That makes sense.
> 
> But what benefit is there is having it as an explicitly "abstract"
> class? Why can't it just be a "normal" class definition which you
> inherit from?
> 
> Sorry to be so dense
> 
> Al 
> 
>> -Original Message-
>> From: Jasper Bryant-Greene [mailto:[EMAIL PROTECTED]
>> Sent: 23 October 2005 09:19
>> To: Alan Lord
>> Cc: php-general@lists.php.net
>> Subject: Re: [PHP] Abstract Classes?
>> 
>> On Sun, 2005-10-23 at 08:54 +0100, Alan Lord wrote:
>>> Hi All,
>>> 
>>> I have started reading a couple of books about PHP 5 and
>> whilst most 
>>> of it is comprehensible even to me :-), I fail to
>> understand WHY there
>>> is such a thing as an abstract class or method?
>>> 
>>> I think I understand what it is: A class that can't itself be
>>> instantiated, only inherited from, or a method that
>> describes itself
>>> only in terms of what properties it accepts but no implementation
>>> detail.
>>> 
>>> But could someone explain why I would want to use this? I'm
>> sure it is 
>>> very useful but I can't quite see the benefit...
>> 
>> Hi Alan
>> 
>> Here's an example from an application framework I've been working on.
>> 
>> It has classes to represent the different HTTP response statuses (like
>> 301 Moved Permanently, 304 Not Modified etc.) with required
>> and forbidden headers for each and different characteristics
>> (like no request-body allowed etc).
>> 
>> I have an Abstract class called HTTP_Response, from which
>> HTTP_Response_Moved_Permanently, HTTP_Response_Not_Modified,
>> and many others all inherit.
>> 
>> The reason HTTP_Response is abstract is because there's no
>> such thing as an HTTP_Response on its own. It has to be a
>> specific type of HTTP Response, that is a 301 Moved
>> Permanently or a 304 Not Modified.
>> 
>> Does that help?
>> 
>> --
>> Jasper Bryant-Greene
>> General Manager
>> Album Limited
>> 
>> e: [EMAIL PROTECTED]
>> w: http://www.album.co.nz/
>> p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
>> a: PO Box 579, Christchurch 8015, New Zealand
>> 
>> 


Thank you,
Colin Shreffler
Principal
303.349.9010 - cell
[EMAIL PROTECTED]

Warp 9 Software, LLC.
6791 Halifax Avenue
Castle Rock, CO 80104

Confidentiality Notice: The information in this e-mail may be confidential
and/or privileged. This e-mail is intended to be reviewed by only the
individual or organization named in the e-mail address. If you are not the
intended recipient, you are hereby notified that any review, dissemination
or copying of this e-mail and attachments, if any, or the information
contained herein, is strictly prohibited.

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



RE: [PHP] Abstract Classes?

2005-10-23 Thread Colin Shreffler
I don't particularly care for this explanation as it makes abstract classes
out to be a mere convention of some kind during the development life-cycle.

While I can see this as a potentially convenient byproduct of the fact that
an abstract class cannot be directly instantiated, this is NOT the whole
story as they do have a much greater purpose:  They provide polymorphism and
encapsulation to class hierarchies.

Certainly you can't instantiate an abstract class, but abstract classes
exist so that the implementation details of certain methods can be deferred
to their derived classes further down the inheritance hierarchy.  Abstract
classes can also contain implementations for other non abstract methods.

Abstract classes and Interfaces can be used in combination in MANY different
patterns and frameworks.

I think that I know what you might be getting at here, but it is not true to
say it would be a class that shouldn't be instantiated as a 'sanity check'
for junior developers.  It should be used to define classes that are truly
abstract; those where it doesn't necessarily make sense to have a 'physical'
manifestation but where it would provide reusable code to its derived
classes.

An example of an abstract class might be 'Vehicle'.  Well that is too vague
(abstract) so you wouldn't really instantiate it.  Instead you'd define more
useable derived 'concrete' classes like Car, Truck, Scooter, Airplane,
Bicycle, or Skateboard.  Each of these are well defined so it makes sense
for these to non-abstract.

Each of these derived classes would then override the Vehicle's abstract
function start() for example, because each one would do this in a different
way.  But by defining 'Vehicle' as abstract and defining the abstract
function start() in it (because 'Vehicle' itself would not have an
implementation for start()), you guarantee that each derived class MUST
provide its own unique implementation for that function.

Colin

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Sunday, October 23, 2005 11:12 PM
To: Alan Lord
Cc: 'Jasper Bryant-Greene'; php-general@lists.php.net
Subject: RE: [PHP] Abstract Classes?

On Sun, October 23, 2005 5:40 am, Alan Lord wrote:
> But what benefit is there is having it as an explicitly "abstract"
> class? Why can't it just be a "normal" class definition which you
> inherit from?

It could be just a normal class...

But assume you're working on a team with a LOT of programmers, which
is where OO really shines.

Then assume some of those programmers are... less experienced... than
others.

They're not supposed to instantiate that one Class, because it doesn't
make any sense to do that, and it's bound to cause errors somewhere
else down the line.

Have an "abstract" class as a formal definition means that if you KNOW
it should never get instantiated, you have a Safety Check on it.

The compiler can error out if somebody, like our Junior Programmer,
tries to instantiate it.

If it's just a "normal" class, maybe Junior manages to make things
work (God knows how) even while instantiating a Class that was never
meant to be instantiated, and that the Expert Programmers would KNOW
was wrong.

It's just a Sanity Check, basically.

So, sure, it COULD be a normal class, if you want to assume nobody
will ever make the mistake of instantiating it...  Or it could be an
abstract class, and if somebody screws up and instantiates it, they'll
know right away and fix it before the problem goes any further.

Hope that helps.

-- 
Like Music?
http://l-i-e.com/artists.htm

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

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



Re: [PHP] Why this doesn't work ?

2005-10-24 Thread Colin Shreffler
It looks to me like you forgot to specify the table in your query:

SELECT COUNT (login) FROM  WHERE login = '$login'

> Hi,
>
> Why this doesn't work ?
>
> ---
> $query = "SELECT COUNT (login) FROM WHERE login = '$login'";
> $result = mysql_query($query);
> mysql_fetch_row($result);
> ---
>
> It gives me
> Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
> result resource in /var/www/html/registar_action.php on line 22
>
> Any help would be apreciated.
>
> Warm Regards,
> Mário Gamito
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>


Thank you,
Colin Shreffler
Principal
303.349.9010 - cell
928.396.1099 - fax
[EMAIL PROTECTED]

Warp 9 Software, LLC.
6791 Halifax Avenue
Castle Rock, CO 80104

Confidentiality Notice: The information in this e-mail may be confidential
and/or privileged. This e-mail is intended to be reviewed by only the
individual or organization named in the e-mail address. If you are not the
intended recipient, you are hereby notified that any review, dissemination
or copying of this e-mail and attachments, if any, or the information
contained herein, is strictly prohibited.

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



Re: [PHP] Calling PostgreSQL & MySQL Stored Procedures - SOLVED

2005-10-24 Thread Colin Shreffler
After further investigation I found that using the 'mysqli' object and
corresponding extension library will allow you to execute MySQL stored
procedures from PHP.

documentation can be found at:

http://www.php.net/manual/en/ref.mysqli.php

cheers
-c

> On Sat, October 22, 2005 12:55 pm, Colin Shreffler wrote:
>> Can any one please tell me how you call a stored procedure in either
>> PostgreSQL or MySQL from php?
>
> WILD GUESS:
>
> $query = "call silly_sproc()";
> mysql_query($query, $connection) or die(mysql_error($connection));
> pg_exec($connection, $query) or die(pg_last_error($connection));
>
> With an argument is left as an exercise to the reader.
>
> HINT: Stuff whatever you would type in the mysql/psql monitor into $query
>
> No promise this works, as I've only done user-defiend functions rather
> than stored procedures (unless those are the same...) in PostgreSQL,
> and my webhost's MySQL probably ain't up to stored procedures yet.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
>
>
>


Thank you,
Colin Shreffler
Principal
303.349.9010 - cell
928.396.1099 - fax
[EMAIL PROTECTED]

Warp 9 Software, LLC.
6791 Halifax Avenue
Castle Rock, CO 80104

Confidentiality Notice: The information in this e-mail may be confidential
and/or privileged. This e-mail is intended to be reviewed by only the
individual or organization named in the e-mail address. If you are not the
intended recipient, you are hereby notified that any review, dissemination
or copying of this e-mail and attachments, if any, or the information
contained herein, is strictly prohibited.

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