php-general Digest 23 Sep 2010 06:25:16 -0000 Issue 6955
Topics (messages 308258 through 308263):
Re: ZipArchive, but without files
308258 by: Jonathan Mills
308259 by: Carlos Medina
Re: Database Administration
308260 by: Tom Barrett
308261 by: Bastien Koert
Re: Copying an Object
308262 by: Daniel Kolbo
308263 by: Peter Lind
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 22/09/2010 12:11, Viacheslav Chumushuk wrote:
> Hello.
> As I understand you in a right way you need next function
> http://ua.php.net/manual/en/function.gzcompress.php
Thanks for the suggestion Viacheslav , but I'd trying to
the create the complete zipfile structure, gzcompress() just
compresses the file's data (and in a slightly different manner
to what ZIP does - the first and last 4 bytes are different to
what zip produces) and, probably more importantly, doesn't
add the file name headers on either end
But the principle - ie something that returns a "string" -
is what I'm looking for.
Kind Regards
Jonathan
--- End Message ---
--- Begin Message ---
Am 22.09.2010 17:32, schrieb Jonathan Mills:
On 22/09/2010 12:11, Viacheslav Chumushuk wrote:
Hello.
As I understand you in a right way you need next function
http://ua.php.net/manual/en/function.gzcompress.php
Thanks for the suggestion Viacheslav , but I'd trying to
the create the complete zipfile structure, gzcompress() just
compresses the file's data (and in a slightly different manner
to what ZIP does - the first and last 4 bytes are different to
what zip produces) and, probably more importantly, doesn't
add the file name headers on either end
But the principle - ie something that returns a "string" -
is what I'm looking for.
Kind Regards
Jonathan
Hi Jonathan,
and what if you serialize your String? You can save Objects in it...
Regards
Carlos
--- End Message ---
--- Begin Message ---
Hmm..
I am familiar with PMA. I would for the purpose of this project consider it
too technical for the target user base. The point is to create a GUI layer
that would manage these things.
For example, the 'add client' screen would ask for four things; name,
description, username and password. Then behind the scenes a database would
be created, the user created, permissions granted and a pre-configure set of
tables built (and populated).
My reservations come from security issues (which, as an aside, are also
discussed about PMA), allowing a normal user account CREATE and GRANT on the
database.
Maybe I'm being too fuddy-duddy cautious.
--- End Message ---
--- Begin Message ---
On Wed, Sep 22, 2010 at 4:35 PM, Tom Barrett <[email protected]> wrote:
> Hmm..
>
> I am familiar with PMA. I would for the purpose of this project consider it
> too technical for the target user base. The point is to create a GUI layer
> that would manage these things.
>
> For example, the 'add client' screen would ask for four things; name,
> description, username and password. Then behind the scenes a database would
> be created, the user created, permissions granted and a pre-configure set of
> tables built (and populated).
>
> My reservations come from security issues (which, as an aside, are also
> discussed about PMA), allowing a normal user account CREATE and GRANT on the
> database.
>
> Maybe I'm being too fuddy-duddy cautious.
>
Not at all. What I would suggest is that you create a separate mysql
user that is used exclusively by the script to do the create stuff.
The regular application user account should not have those privileges
at all.
Another option, if immediate response is not required, is to save this
data into the system for a cron script with another user account to
run.
Is there a reason for you not to place all the data in one DB and just
separate them out based on user id, to ensure they only see their own
data?
--
Bastien
Cat, the other other white meat
--- End Message ---
--- Begin Message ---
On 9/22/2010 9:11 AM, chris h wrote:
>
> You could create a method of class B that takes an object of class A as
> a parameter and copies each property line by line (or method of class A
> that takes an object of class B...). If you don't want to add a method
> you could just do the same thing, but procedurally. The issue with this
> (aside from being bad oop) is that you can't copy private properties
> unless you have all the required getters and setters. The issue with
> both of these is that it's ugly, high maintenance code.
>
> There is the iterator class, extending from which would allow you
> iterate through all of your properties in a foreach, but if you don't
> want to add a new method then you likely don't want to add a parent class.
>
> I don't care for any of these options, but as far as I know there's no
> internal PHP mechanism to to copy all the properties from one object to
> another object of a different class - please correct me if I'm wrong.
> Is it possible that there's a more elegant solution to your problem
> that does not include a mass copy of all an object's properties? (e.g.
> using statics like Mr Bungle suggested or perhaps some nifty design
> pattern?)
>
>
> Chris H.
>
>
>
>
> On Wed, Sep 22, 2010 at 7:35 AM, Daniel Kolbo <[email protected]
> <mailto:[email protected]>> wrote:
>
> Hello PHPers,
>
> I have:
>
> class A {
> ...code
> }
>
> class B extends A {
> ...code
> }
>
> $a = new A();
>
> $b = new B();
>
> I would like to get all of the properties of $a into $b by value. Class
> A extends 3 other classes. I would like a way to not have to manage a
> 'copy' method in B if A or one of the subclasses of A change.
>
> I was reading about clone, but this doesn't really seem to help me in
> this situation.
>
> How can I copy $a into $b?
>
> Thanks,
> dK
> `
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Hello,
Thank you Mr. Bungle, Chris, Nathan, and Carlos Medina.
Nathan, your first response though not exactly what I was looking for
was still instructive to me thanks. I almost started to implement your
second response but I decided against it as I still wanted class B to
extend class A (and i didn't want the unused members of A to be hanging
around in the objects of B). Also, I already had __call methods
implemented in the most base class level. I could have handled this by
calling parent::__call from the child levels if the methods from object
$a were not found. It would have worked.
Instead I implemented a series of "copy" functions in each of the
extended classes and cascaded through each of the extended classes.
Each copy method calls parent::copy($obj) to copy the elements of the
extended class.
My classes weren't too crazy just 3-5 members each (all of protected
typed) so it'll work for now.
All in all it was a learning curve. I still think PHP needs to have
this functionality built in.
Say you have two classes: human and male. Further, say male extends
human. Let's say you have a human object. Then later you want to make
that human object a male object. This seems to be a pretty reasonable
thing to request of our objects. This type of thing would especially be
easy if objects of parent classes could be cast as an object of its
extended class.
Thanks again for all of your input,
dK
`
--- End Message ---
--- Begin Message ---
On 23 September 2010 02:14, Daniel Kolbo <[email protected]> wrote:
*snip*
> On 9/22/2010 9:11 AM, chris h wrote:
> Say you have two classes: human and male. Further, say male extends
> human. Let's say you have a human object. Then later you want to make
> that human object a male object. This seems to be a pretty reasonable
> thing to request of our objects.
Perhaps if you're a C# programmer, but the PHP way of thinking is
radically different.
C#: This object is whatever it was currently cast to (if possible)
PHP: This object is this object, whatever it was created as
If you have a need to make an object switch class in PHP, then there's
a 99% chance you're working against, not with the language.
> This type of thing would especially be
> easy if objects of parent classes could be cast as an object of its
> extended class.
I'll hazard a guess and say you didn't start programming in PHP but in
something else.
Regards
Peter
--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>
--- End Message ---