php-general Digest 23 Jul 2010 05:28:27 -0000 Issue 6860

Topics (messages 307097 through 307108):

session.gc_ : maxlifetime vs probability/divisor : which has higher priority?
        307097 by: Keith

Re: Does class length slow down performance
        307098 by: Jay Blanchard
        307099 by: Sebastian Ewert
        307100 by: David Harkness

Re: PHP database interface layer
        307101 by: Marc Guay
        307102 by: Floyd Resler
        307103 by: Nathan Nobbe
        307104 by: Peter Lind
        307105 by: Marc Guay
        307107 by: Shawn McKenzie

SOAP ERROR - Encoding
        307106 by: Augusto Flavio

opening link in new window
        307108 by: David Mehler

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
From what I read, the session will remain even after maxlifetime until the
next round session garbage clearance.
This is fine for me.
1) However, will the garbage clearance delete the session whose maxlifetime not reach yet? 2) maxlifetime is referrenced to most recent script execution time which has session_start() statement or the first time this session id been created?

3)What does the statement below mean?
"If different scripts have different values of session.gc_maxlifetime but share the same place for storing the session data then the script with the minimum value will be cleaning the data."

Does this mean that each script file called within same session, can have different maxlifetime? I thought each time each script been called for a particular session will overwrite the previous setting if I have I set it with ini_set().

Does the selection of minimum value of the statement above applied to individual session, or refer to all session within the same folder?

4) How to make sure that the PHP session remained as long as user not logout, and if the maxlifetime reach, I can prompt user to decide whether to continue the session or abort it.

Thanks for advice.
--- End Message ---
--- Begin Message ---
[snip]
> So you think that a length of 850 lines won't lead to a performance
> problem?

No, I don't think there will be problems. I also think the only way
you'll ever find out whether it *will* be a problem in your system is
by testing.
[/snip]

^this to the max

[snip]
> The site is not online yet. I just wanted to know when to split a
class
> and if there are performance problems with to long classes.
[/snip]

I will try to find some good links for you but there is one book that I
can whole-heartedly recommend (I have all of my younger, um, less
experienced programmers read it);

Head First Object-Oriented Analysis and Design
http://oreilly.com/catalog/9780596008673/

It is a quick read, the exercises are fun and even though they focus on
Java the principles apply across al OOP languages.

As for splitting a class it doesn't matter the size of the class as long
as the class does one thing and does it really well. We have some very
large classes (remember - you are trying to describe an object and all
of the methods for that object) and some very small (under 25 lines
including comments) classes. The one characteristic that sticks out is
that they all do one thing really well.

http://www.wdvl.com/Authoring/Scripting/Tutorial/objects.html (I am
starting you a few pages into the article) is a good basic discussion of
OOP.


--- End Message ---
--- Begin Message ---
> No, I don't think there will be problems. I also think the only way
> you'll ever find out whether it *will* be a problem in your system is
> by testing.

I've started some benchmarks with apachebench but the problem is I don't
have any benchmarks to compare with. And so I started looking for
something to change.

> I will try to find some good links for you but there is one book that I
> can whole-heartedly recommend (I have all of my younger, um, less
> experienced programmers read it);
> 
> Head First Object-Oriented Analysis and Design
> http://oreilly.com/catalog/9780596008673/

Thanks to all. My question is answered and I have some lecture for the
next week.

Greets,
Sebastian


--- End Message ---
--- Begin Message ---
On Thu, Jul 22, 2010 at 2:40 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk>wrote:

> The larger a script or class is, the more memory this uses per instance.
>

This is not quite true. When the script is loaded, it requires a fixed
amount of memory to parse it. The larger it is, the more memory it requires.
Next, the script itself is executed, running any top-level code (not in a
class or global function). If that includes any require/include statements,
those scripts are loaded (if necessary). If it creates objects, that takes
more memory.

However, the size of each instance of the class is affected only by the data
it stores--not the number or length of its methods. PHP creates a single
internal Class object to contain the methods, and this indeed takes memory
proportional to the number of methods, but this doesn't affect the
instances. Each instance stores only its instance properties such as
$this->firstName.

This correction aside, the advice here is spot on: split your classes based
on responsibilities. The reason for this has more to do with ease of
development than performance. Say you have one monster class filled with
static methods. If your application uses most of those methods for each
request, splitting it will have no performance benefit because both scripts
will end up being loaded anyway. But if you can group the methods into
logical subsystems, they will be easier to understand and work with.

Peace,
David

--- End Message ---
--- Begin Message ---
> i recommend propel
> http://www.propelorm.org/

Holy Moses that thing is a monster.  It requires installing extra
libraries (Phing) in order to create an XML schema reverse-engineered
from my existing database.  The code looks simple enough but that
installation is brutal.  Any other suggestions?  I'm thinking of
sticking with good ol' hand coding and a few helper classes.

Marc

--- End Message ---
--- Begin Message ---
On Jul 22, 2010, at 3:14 PM, Marc Guay wrote:

>> i recommend propel
>> http://www.propelorm.org/
> 
> Holy Moses that thing is a monster.  It requires installing extra
> libraries (Phing) in order to create an XML schema reverse-engineered
> from my existing database.  The code looks simple enough but that
> installation is brutal.  Any other suggestions?  I'm thinking of
> sticking with good ol' hand coding and a few helper classes.
> 
> Marc
> 

I kind of had the same reaction when I saw it!  I started playing around with 
it and realized that if I ever make any database changes I'm going to have to 
regenerate everything!  Seems a bit cumbersome to me but I'm an "good ol' hand 
coding and a few helper classes" programmer myself!  I wound up creating a very 
light-weight yet flexible framework that has served me well over the past few 
years.  I've been thinking about releasing it but it doesn't follow the 
traditional model of most of the MVC frameworks I've seen.

Take care,
Floyd


--- End Message ---
--- Begin Message ---
On Thu, Jul 22, 2010 at 1:14 PM, Marc Guay <marc.g...@gmail.com> wrote:

> > i recommend propel
> > http://www.propelorm.org/
>
> Holy Moses that thing is a monster.  It requires installing extra
> libraries (Phing) in order to create an XML schema reverse-engineered
> from my existing database.  The code looks simple enough but that
> installation is brutal.  Any other suggestions?  I'm thinking of
> sticking with good ol' hand coding and a few helper classes.
>
> Marc
>

so you spend a little time up front to sav tons of coding time in the
future...  change your schema; re-generate the base layer.., o yeah, and it
preserves custom logic too (upon regeneration), since that resides in sub
classes.

i used to hand write db wrapper classes but found it tedious and tended to
result in a lack of cohesion through the classes themselves, not to mention
being error prone.

-nathan

--- End Message ---
--- Begin Message ---
On 22 July 2010 21:14, Marc Guay <marc.g...@gmail.com> wrote:
>> i recommend propel
>> http://www.propelorm.org/
>
> Holy Moses that thing is a monster.  It requires installing extra
> libraries (Phing) in order to create an XML schema reverse-engineered
> from my existing database.  The code looks simple enough but that
> installation is brutal.  Any other suggestions?  I'm thinking of
> sticking with good ol' hand coding and a few helper classes.
>

Let me repeat myself: did you have a look at Doctrine2?

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 ---
--- Begin Message ---
> Let me repeat myself: did you have a look at Doctrine2?

Hi Peter,

I didn't mean to ignore your suggestion, I just got extremely
overwealmed by the Doctrine website and didn't even have a response.
I get the impression that, like Zend and others, learning how to
install and use that would take longer than my 'little' website is
worth.  Maybe someday when I'm working for a more patient employer
who's willing to pay me to learn.  Insert laughter here.

Marc

--- End Message ---
--- Begin Message ---
On 07/22/2010 08:35 AM, Marc Guay wrote:
> Hi everyone,
> 
> I've built a fairly large normalized database schema for a project.
> This is fun for me as I like thinking about how everything is
> interconnected.  Foreign keys are all set up, many-to-many tables are
> go, etc, and so on.   But now it's time to create an interface between
> that database and the website using PHP.  I've searched the web and
> this is obviously a very common problem with many solutions, but I
> can't help but feel that all of the logic I've built into the database
> is worth nothing once I start coding.  I found this
> article/presentation that essentially sums up my frustration:
> http://mag-sol.com/talks/lpm/2006/orm/.  Up until now I've been
> working on smaller projects with only a few tables that don't really
> relate to each other, and have found this tool
> (http://www.ricocheting.com/code/php/mysql-database-class-wrapper)
> very handy for the reasons he explains, but I'm looking for something
> a little different.  I've looked at RedBean and it seems pretty handy,
> but it also requires me to redefine all of the foreign keys I've
> already defined, which is annoying.  Any hope of something like
> 
> // Get company where name='Widgets Inc.' or id=1 or....
> $company = $db->get_company("name='Widgets Inc.'");
> 
> // Get all clients joined to the company
> $clients = $company->get_clients();
> 
> // Get all projects joined to the client
> $projects = $clients->get_projects();
> 
> ?

You may not want a full fledged framework, but I would recommend
CakePHP.  Now they have naming conventions for tables/columns, that if
you follow, makes it sooo easy, but if you already have your schema
built it can use that just as easily.

Just run the cake script, enter db details, it will enumerate tables and
columns and ask which are related by which keys and even let you enter
validation rules etc.  It then builds a skeleton app with all the models
for your schema and will even generate test.

-- 
Thanks!
-Shawn
http://www.spidean.com

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


I created a simple wsdl web service. Everything works fine, but when I fill
the fields with accents and send the soap request, the PHP returns me an
error:


*Fatal error*: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding:
string 'ol\xe1...' is not a valid utf-8 string in PATH\cilent.php 16 Stack
trace: #0 [internal function]: SoapClient->__call('Send', Array) #1
PATH\cilent.php(16): SoapClient->Send(Array) #2 {main} thrown in *
PATH\cilent.php* on line *16*


I tested this same request using the eclipse web service explorer(It's a
java client web service inside the eclipse IDE) and the response was ok.


I found few topics about this issue on the google. One related solution to
this problem is use the utf8_encode() function. I tried add this function
before to send the soap request but didnt worked.


I think that this problem is in the PHP soap client because using the
eclipse web service explorer it works fine.


Here is my php soap client:


$client = new SoapClient('http://app/webservice.wsdl');
$return = $client->Send(array('token' => '123123', 'message' => array(
'text' => 'This is a string with special characters á é í ó ú', 'dest' =>
'John', 'sender' => 'Augusto')));

As I said I tried to use the utf8_encode() here:

$return = $client->Send(array('token' => '123123', 'message' => array(
'text' => utf8_encode('This is a string with special characters á é í ó ú'),
'dest' => 'John', 'sender' => 'Augusto')));

But the problem still.

I tried also add the propertie defencoding in the soap server:

$server->soap_defencoding = 'UTF-8';

But still not working.


What I'm missing?



Thanks



Augusto Morais

--- End Message ---
--- Begin Message ---
Hello,
I've got a page with an external link. I'd like to open it in a new
window, but i'm using the xhtml 1.0 strict dtd so this isn't possible.
I was wondering if php could pull this off? Failing that, and not
really wanting to go there, would javascript work for this?
Thanks.
Dave.

--- End Message ---

Reply via email to