php-general Digest 29 Dec 2009 21:09:47 -0000 Issue 6512

Topics (messages 300717 through 300730):

Multiple Inheritance Needed in OOP?
        300717 by: Daniel Kolbo
        300722 by: Larry Garfield

MySQL Increment/Decrement
        300718 by: Ben Miller
        300719 by: Robert Cummings
        300720 by: Bipper Goes!
        300721 by: Eric Lee
        300724 by: muzy
        300728 by: Phpster

Merry Xmas and Happy New year
        300723 by: Gautam Bhatia

Solution: [PHP] Fatal error: Call to undefined function: mysqli_connect() in
        300725 by: chris_brech.hotmail.com

[php] Question about jsmin-php code
        300726 by: hack988 hack988
        300727 by: Daniel Egeberg

Re: Noob stuff - Zend/Opcode/Cache/Optimizer
        300729 by: Shahar Evron

output buffer
        300730 by: Marc Fromm

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 ---
Hello,

Okay so PHP designers explicitly decided against multiple inheritances,
but aren't there legitimate needs for multiple inheritance in OOP?

For example, consider the following three classes (A,B,C) with the
following properties (a number is a distinct property or method).

A: 1, 2, 3
B: 1,    3
C: 1, 2,

I would like to set the 3 classes up so that no object has 'extra'
properties than it requires, so that no property has to be
declared/defined in two or more classes, and so that we are strictly
using single inhertiance.  I don't think it's possible.  I've been
incorrect beforee...If i'm incorrect please let me know how to set this
up as a single inhertance class structure.

If this is not possible, why doesn't the PHP community implement
multiple inheritance?  (I'm anticipating that someone will say, you
simply need to redefine what you are calling your objects so that the
properties do permit a single inheritance...)

I'm very interested to hear why there is the dogma of single inheritance
only.

Thanks,
dK
`

--- End Message ---
--- Begin Message ---
On Monday 28 December 2009 9:45:03 pm Daniel Kolbo wrote:
> Hello,
>
> Okay so PHP designers explicitly decided against multiple inheritances,
> but aren't there legitimate needs for multiple inheritance in OOP?
>
> For example, consider the following three classes (A,B,C) with the
> following properties (a number is a distinct property or method).
>
> A: 1, 2, 3
> B: 1,    3
> C: 1, 2,
>
> I would like to set the 3 classes up so that no object has 'extra'
> properties than it requires, so that no property has to be
> declared/defined in two or more classes, and so that we are strictly
> using single inhertiance.  I don't think it's possible.  I've been
> incorrect beforee...If i'm incorrect please let me know how to set this
> up as a single inhertance class structure.
>
> If this is not possible, why doesn't the PHP community implement
> multiple inheritance?  (I'm anticipating that someone will say, you
> simply need to redefine what you are calling your objects so that the
> properties do permit a single inheritance...)
>
> I'm very interested to hear why there is the dogma of single inheritance
> only.
>
> Thanks,
> dK
> `

Because pure multiple inheritance can lead to all sorts of highly weird 
behavior when you don't know which parent class you mean at any given time.  
Single inheritance is just easier to wrap your head around, and wrap the 
compiler's head around.

What you're looking for is composition, which can do pretty much what you're 
looking for.  See my last reply to you on this list from Christmas day.

There's been some discussion of implementing "traits" in later versions of 
PHP, but no concrete patches so far.

-- 
Larry Garfield
[email protected]

--- End Message ---
--- Begin Message ---
I hope this isn't a bone-head question - Is there a MySQL query that will
increment/decrement the value in an integer column with a single query - in
other words, I don't have to run a SELECT query to get the value,
add/subtract to/from the value, and then run an UPDATE query to store the
new value?

 

Thanks in advance.

 

Ben


--- End Message ---
--- Begin Message ---
Ben Miller wrote:
I hope this isn't a bone-head question - Is there a MySQL query that will
increment/decrement the value in an integer column with a single query - in
other words, I don't have to run a SELECT query to get the value,
add/subtract to/from the value, and then run an UPDATE query to store the
new value?

You mean:

    UPDATE table SET column = column + 1;

?

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---
--- Begin Message ---
UPDATE SQLTABLE SET count = (count+1) WHERE PromoID=1

Is this valid for your issue?  I have no way of testing or toying

On Mon, Dec 28, 2009 at 8:54 PM, Ben Miller <[email protected]> wrote:

> I hope this isn't a bone-head question - Is there a MySQL query that will
> increment/decrement the value in an integer column with a single query - in
> other words, I don't have to run a SELECT query to get the value,
> add/subtract to/from the value, and then run an UPDATE query to store the
> new value?
>
>
>
> Thanks in advance.
>
>
>
> Ben
>
>

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

It seems that you can just update the column with a update query like this,

update table set field = field + 1 where some condition

This might be the thing you need.


Eric



On 12/29/09, Ben Miller <[email protected]> wrote:
>
> I hope this isn't a bone-head question - Is there a MySQL query that will
> increment/decrement the value in an integer column with a single query - in
> other words, I don't have to run a SELECT query to get the value,
> add/subtract to/from the value, and then run an UPDATE query to store the
> new value?
>
>
>
> Thanks in advance.
>
>
>
> Ben
>
>

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

I had the same question yesterday (but with SQLite) and there are at least 2 solutions.

The first was already mentioned:

UPDATE table SET value = value + 1 WHERE foo = bar;

The second solution which also works is:

UPDATE table SET value = (SELECT value FROM table WHERE foo = bar) + 1 WHERE foo = bar;


I hope it helps.


Greetings from Germany,


Sebastian

Ben Miller wrote:
I hope this isn't a bone-head question - Is there a MySQL query that will
increment/decrement the value in an integer column with a single query - in
other words, I don't have to run a SELECT query to get the value,
add/subtract to/from the value, and then run an UPDATE query to store the
new value?

Thanks in advance.

Ben




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




On Dec 29, 2009, at 3:10 AM, muzy <[email protected]> wrote:

Hello Ben,

I had the same question yesterday (but with SQLite) and there are at least 2 solutions.

The first was already mentioned:

UPDATE table SET value = value + 1 WHERE foo = bar;

The second solution which also works is:

UPDATE table SET value = (SELECT value FROM table WHERE foo = bar) + 1 WHERE foo = bar;


I hope it helps.


Greetings from Germany,


Sebastian

Ben Miller wrote:
I hope this isn't a bone-head question - Is there a MySQL query that will increment/decrement the value in an integer column with a single query - in
other words, I don't have to run a SELECT query to get the value,
add/subtract to/from the value, and then run an UPDATE query to store the
new value?


Thanks in advance.


Ben





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


You may run into race conditions and contention when handling auto- incrementimg this way. Best to isolate the SQL into a transaction to avoid this

Bastien

Sent from my iPod

--- End Message ---
--- Begin Message ---
Hey Guys,
                    Have a great new year and merry Christmas.


Regards,
Gautam Bhatia
[email protected] 



--- End Message ---
--- Begin Message ---
After trying everything everyone said in here, I finally had a clear enough 
head to read through my logs and both my Apache httpd.conf and my PHP6 php.ini 
files.  I realized that in my Apache error log, it was listing the fact that 
PHP could not load the modules for mysqli and xmlrpc (or something like that, 
but the focus here is MySQL).

Instead of reinstalling everything, as I'm a stubborn person, I found a line in 
the php.ini file that in our case probably should not be commented out.

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
; extension_dir = "ext"

That last line (for Windows), remove the semi-colon (;), and make sure the 
mysqli modules you need are in C:\php\ext, after doing this, my MySQL was 
finally able to connect with PHP.

As a final note, Apache was telling me it was looking for the missing modules 
in C:\php6\ which is not a setting I ever set, and that directory does not 
exist in the php.ini or apache configuration files, so it seems to be a default 
directory for PHP.  I did not see any benefit for cause for having an extra 
php.ini in a C:\php6 folder as some have suggested, so I would suggest trying 
to avoid that unless it turns out to be necessary.

Also, some people recommended putting the required modules in multiple 
directories, whereas I would recommend ensuring that the original installation 
modules are left where they are, and if you are to make copies, try to make 
sure all your modules are the same versions, and that you only make additional 
copies to the C:\php\ext folder or Apache's own includes folder if necessary.  
Do not make extra copies to C:\php6 or your system32 folders - this will add 
clutter, and possibly cause issues in the future.

I hope this helped.  Just stay calm, be patient, relax - you will find the 
issue as long as you're clear minded and resist frustration.  Have a great day.

PS: I registered just so I could share this, lol.

--
This message was sent on behalf of [email protected] at openSubscriber.com
http://www.opensubscriber.com/message/[email protected]/11675992.html

--- End Message ---
--- Begin Message ---
I'm see some code from jsmin-php like follow:

<?php
error_reporting(E_STRICT);

fwrite(STDERR, memory_get_peak_usage(true)."\n");

require './jsmin.php';
echo JSMin::minify(file_get_contents('ext-all-debug.js'));

fwrite(STDERR, memory_get_peak_usage(true)."\n");
?>

I have some question about code
1.what is E_STRICT error level mean?I'm found an explain at
http://www.php.net/manual/en/errorfunc.constants.php
but i don't understand which situation need this level?
2.document for STDERR is at http://php.net/manual/en/wrappers.php.php
but why it write some output to STDERR ?

--- End Message ---
--- Begin Message ---
On Tue, Dec 29, 2009 at 12:07, hack988 hack988 <[email protected]> wrote:
> I have some question about code
> 1.what is E_STRICT error level mean?I'm found an explain at
> http://www.php.net/manual/en/errorfunc.constants.php
> but i don't understand which situation need this level?

E_STRICT is an error level indicating that you are doing something
that will work, but is for whatever reason discouraged. An example
would be using "var $foo;" for class properties instead of using one
of the visibility keywords public/protected/private.

It's basically a way of telling you that you are doing something that
is considered bad practice.

> 2.document for STDERR is at http://php.net/manual/en/wrappers.php.php
> but why it write some output to STDERR ?

The reason why one would want to write to STDERR (as opposed to
STDOUT) is if you are writing error messages. By standard on the
console, STDERR and STDOUT go the same place, but it's possible
redirecting both of these streams. If you redirect some output (STDOUT
specifically) to a file, you might still be interested in getting the
error messages on the screen.

See http://en.wikipedia.org/wiki/Standard_streams for more information
about that. Why your specific script would write to STDERR, I don't
know.

-- 
Daniel Egeberg

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

In general, the Zend Engine is an integral part of PHP (the "engine" so
to speak of PHP). It's open source, and is developed as part of PHP
generally speaking by the same community (or maybe specific people in
that community).

Zend Server (incl. Zend Server CE) is a Zend (the company) product. A
simplistic description of it would be that it's a commercial
distribution of PHP with some extra components - Optimizer+ being one of
them.

The two are very different things, and should not be confused :)

My specific comments follow:

On 29/12/09 17:00 PM, Daniel Kolbo wrote:
> Shawn McKenzie wrote:
> > Daniel Kolbo wrote:
> >> Hello,
> >>
> >> I'm missing some unifying piece of the zend/php puzzle...
> >>
> >> I understand the basics of zend engine opcode, caching the opcode,
> >> optimizing the opcode, and caching the optimized opcode, etc...   The
> >> part I'm struggling with is somewhere in the zend world.
> >>
> >> Under a typical php install where does the zend engine live (like what
> >> file)?
> >
> > I don't think it is separate from PHP itself.  The Zend engine was a
> > rewrite of the PHP execution engine with resource/mem management and
> the
> > API for loadable extensions, etc...  Later adding the PHP 5 OOP stuff.
> >
> >> I am under the impression that I need to install the Zend Server
> >> Community Edition (ZSCE) to get the zend optimizer+.  I thought PHP
> came
> >> with the zend engine...why do i now have to download this ZSCE just to
> >> add a component to the engine i already have?
> >>
> >> 1)  Is there a way to turn on zend optimizer+ component (like in
> php.ini
> >> zend extension) without having to install ZSCE?
> >
> > It is an extension available on the Zend download page.

Unlike "Optimizer", "Optimizer+" is not available as a separate
download, but only as part of Zend Server (and ZSCE). You could
technically just download ZSCE, grab the .so / .dll of Optimizer+ and
add it to any other compatible (same version, similar build) PHP setup.
It may or may not work, and generally at Zend we only test Optimizer+ as
part of Zend Server.

> >
> >> 1.2) If i have to install the ZSCE stack, wouldn't this effectively be
> >> adding another engine on my machine?
> >

You would effectively be adding another PHP installation, so the answer
is technically yes. The Engine is not separate from PHP, so it's not
"another Engine" - it's another installation of PHP.

> > Yes, it is a install of PHP with alot of other stuff bundled in.  So it
> > depends upon what you need and if you want to install/configure PHP
> > yourself with all of these additions, or if you just want to install
> the
> > Zend server.
> >
> >
> Hello Mr. McKenzie,
>
> Thanks for the response.  I do not see zend optimizer+ on:
> http://www.zend.com/en/downloads/
>
> There is a zend optimizer download link, but this is different than zend
> optimizer+.  My understanding is the former facilitates with the use of
> zend gaurd while the latter optimizes the opcode.  I want the latter
> component.

That is generally true - they both do optimizations, while Optimizer
also loads Guard-encoded files and Optimizer+ also does opcode caching
after optimizing it. If you're looking for performance Optimizer+ is the
one you're looking for. That said, it is not available as a separate
download - only as part of ZS/CE.

>
> Where does one obtain the zend optimizer+ component?  (I spent the
> better part of my saturday trying to find it).  I ended up installing
> the zend server community edition to see how it configured its own
> apache and php installs in the httpd.conf and php.ini as a way to shed
> some light on to my understanding.
>
> The zend server is using different libraries then the standard php
> install.  I could try to mimic the behaviour of the zend server
> configuration with my original php configuration; however, I'm a bit
> concerned about only grabbing partial components...maybe i don't need to
> be so worried.  Maybe this plan isn't even possible.

As I mentioned this might or might not work, depending on what PHP
exactly you'll try to run it on. BTW why not just use ZSCE? Which
incompatibilities did you encounter?

Cheers,

Shahar.

>
> I guess i was expecting to google, 'install zend optimizer+ component'
> and find gooooogles of howtos.  Because i don't see this, it makes me
> wonder if i'm trying to do something i oughta not...
>
> My question boils down to:
> How do I extend my current php install to add a component (zend
> optimizer+) to my current php install?
>
> Thanks,
> dK
> `
>
>

-- 
Shahar Evron <[email protected]>

Product Manager
Zend Technologies


--- End Message ---
--- Begin Message ---
I am receiving the "Cannot send session cookie - headers already sent" message 
even though I am using ob_start() at the top of my script.
The php.ini file has output_buffering set to 4096 4096.
My server is running Red Hat Enterprise Linux 5.2
I am using PHP 5.1.6

Is there some other setting I need to adjust to be able to start a session 
within the php script?

Thanks

Marc


--- End Message ---

Reply via email to