php-general Digest 22 Jul 2010 15:14:37 -0000 Issue 6859

2010-07-22 Thread php-general-digest-help

php-general Digest 22 Jul 2010 15:14:37 - Issue 6859

Topics (messages 307082 through 307096):

Re: XML DOM
307082 by: Benjamin Hawkes-Lewis

Does class length slow down performance
307083 by: Sebastian Ewert
307084 by: Ashley Sheridan
307086 by: Sebastian Ewert
307087 by: Jay Blanchard
307088 by: Sebastian Ewert
307090 by: Peter Lind
307092 by: Sebastian Ewert
307093 by: Peter Lind

Re: Question about SQL and Graph nodel trees
307085 by: Tommy Pham

PHP database interface layer
307089 by: Marc Guay
307091 by: Peter Lind
307095 by: Nathan Nobbe
307096 by: Marc Guay

Video lessons
307094 by: Jordan Jovanov

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


--
---BeginMessage---
On 21 Jul 2010, at 19:32, Ben Miller wrote:
 Problem:
 
 If street2 (or any other field) has no value, PHP is outputting the XML node
 as street2 /, which is producing a JS error when I try to call:
 
 script type=text/javascript..
 
 street2 = x[i].getElementsByTagName(street2)[0].childNodes[0].nodeValue;
 
.../script   (Because the requested node has no
 .nodeValue, I'm assuming???)
 
 
 
 Question:
 
 Can I tell PHP to output the XML node as street2/street2 instead of
 street2 / so that JS sees that the object has a value, but the value is 
 (blank)?

street2foo/street2 is syntax that means a street2 element with one 
child node: text node foo.

street2/street2 and street2 / are different syntax that mean the same 
thing: a street2 element with no child nodes.

Your JS property lookup fails because the street2 element has no child nodes. 
Rather than changing your XML serialization to have some sort of opaque 
meaning, why not do one of the following in your JS?

   1. Test to see if the element in question has any child nodes before 
attempting to access the first one:

   if (x[i].getElementsByTagName(street2)[0].childNodes.length  0) ...

   2. Use the textContent and innerText properties to get the text of 
all/any child nodes.

--
Benjamin Hawkes-Lewis---End Message---
---BeginMessage---
Hi,

I'm developing an joomla component and my helper an user classes are
crowing bigger and bigger. The helper class is for static use only.

Does class size decrease performance of my php scripts, even for static
usage?
Is there a general rule when to split a class to keep performance up?

Thanks for reply,
Sebastian

---End Message---
---BeginMessage---
On Thu, 2010-07-22 at 10:49 +0200, Sebastian Ewert wrote:

 Hi,
 
 I'm developing an joomla component and my helper an user classes are
 crowing bigger and bigger. The helper class is for static use only.
 
 Does class size decrease performance of my php scripts, even for static
 usage?
 Is there a general rule when to split a class to keep performance up?
 
 Thanks for reply,
 Sebastian
 
 


How big roughly are we talking here? The larger a script or class is,
the more memory this uses per instance. Out of the box, PHP doesn't have
a way to share the memory space of libraries and classes, so creating
massive scripts for a website is not a great idea.

The typical approach is to break classes down into blocks such that you
need only include per script what you actually need to run that script.

For example, having a full class dedicated to user management would need
somewhere to create a list of users. Now it doesn't make sense to
include this user management class each time you want to create a list
of users, so you could split that method off into a different class
where it can easily be shared without every script loading in lots of
unnecessary code.

That's a very simple example, but it can help beforehand if you sketch
out exactly what you need to do, and then break it down into logical
classes like that. Maybe look at some UML software to help you with
this?

Thanks,
Ash
http://www.ashleysheridan.co.uk


---End Message---
---BeginMessage---
Ashley Sheridan wrote:
 On Thu, 2010-07-22 at 10:49 +0200, Sebastian Ewert wrote:
 
 Hi,

 I'm developing an joomla component and my helper an user classes are
 crowing bigger and bigger. The helper class is for static use only.

 Does class size decrease performance of my php scripts, even for static
 usage?
 Is there a general rule when to split a class to keep performance up?

 Thanks for reply,
 Sebastian


 
 
 How big roughly are we talking here? The larger a script or class is,
 the more memory this uses per instance. Out of the box, PHP doesn't have
 a way to share the memory space of libraries and classes, so creating
 massive scripts for a website is not a great idea.
 

The user object contains 850 Lines and about 50 

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

2010-07-22 Thread php-general-digest-help

php-general Digest 23 Jul 2010 05:28:27 - 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


--
---BeginMessage---
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---
---BeginMessage---
[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---
---BeginMessage---
 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---
---BeginMessage---
On Thu, Jul 22, 2010 at 2:40 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 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 

Re: [PHP] XML DOM

2010-07-22 Thread Benjamin Hawkes-Lewis
On 21 Jul 2010, at 19:32, Ben Miller wrote:
 Problem:
 
 If street2 (or any other field) has no value, PHP is outputting the XML node
 as street2 /, which is producing a JS error when I try to call:
 
 script type=text/javascript..
 
 street2 = x[i].getElementsByTagName(street2)[0].childNodes[0].nodeValue;
 
.../script   (Because the requested node has no
 .nodeValue, I'm assuming???)
 
 
 
 Question:
 
 Can I tell PHP to output the XML node as street2/street2 instead of
 street2 / so that JS sees that the object has a value, but the value is 
 (blank)?

street2foo/street2 is syntax that means a street2 element with one 
child node: text node foo.

street2/street2 and street2 / are different syntax that mean the same 
thing: a street2 element with no child nodes.

Your JS property lookup fails because the street2 element has no child nodes. 
Rather than changing your XML serialization to have some sort of opaque 
meaning, why not do one of the following in your JS?

   1. Test to see if the element in question has any child nodes before 
attempting to access the first one:

   if (x[i].getElementsByTagName(street2)[0].childNodes.length  0) ...

   2. Use the textContent and innerText properties to get the text of 
all/any child nodes.

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



[PHP] Does class length slow down performance

2010-07-22 Thread Sebastian Ewert
Hi,

I'm developing an joomla component and my helper an user classes are
crowing bigger and bigger. The helper class is for static use only.

Does class size decrease performance of my php scripts, even for static
usage?
Is there a general rule when to split a class to keep performance up?

Thanks for reply,
Sebastian


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



Re: [PHP] Does class length slow down performance

2010-07-22 Thread Ashley Sheridan
On Thu, 2010-07-22 at 10:49 +0200, Sebastian Ewert wrote:

 Hi,
 
 I'm developing an joomla component and my helper an user classes are
 crowing bigger and bigger. The helper class is for static use only.
 
 Does class size decrease performance of my php scripts, even for static
 usage?
 Is there a general rule when to split a class to keep performance up?
 
 Thanks for reply,
 Sebastian
 
 


How big roughly are we talking here? The larger a script or class is,
the more memory this uses per instance. Out of the box, PHP doesn't have
a way to share the memory space of libraries and classes, so creating
massive scripts for a website is not a great idea.

The typical approach is to break classes down into blocks such that you
need only include per script what you actually need to run that script.

For example, having a full class dedicated to user management would need
somewhere to create a list of users. Now it doesn't make sense to
include this user management class each time you want to create a list
of users, so you could split that method off into a different class
where it can easily be shared without every script loading in lots of
unnecessary code.

That's a very simple example, but it can help beforehand if you sketch
out exactly what you need to do, and then break it down into logical
classes like that. Maybe look at some UML software to help you with
this?

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Question about SQL and Graph nodel trees

2010-07-22 Thread Tommy Pham

 -Original Message-
 From: Tim Gallagher [mailto:tgallag...@danati.com]
 Sent: Wednesday, July 21, 2010 12:49 PM
 To: Andrew Ballard
 Cc: php-general@lists.php.net
 Subject: RE: [PHP] Question about SQL and Graph nodel trees
 
 Thank you for the informaiton.  I did see that code but it looks like it is
 formatted for MSSQL and was unable to get it to work for Mysql.
 
 Tim
 

@Tim, You'll have to migrate the stored procedures (SP) from MSSQL to MySQL 
(aka stored programs).  Each DBMS have their own way of implementing the SP.
http://dev.mysql.com/doc/refman/5.1/en/stored-programs-views.html

@Andrew, interesting link! Thanks!

Regards,
Tommy

 
 From: Andrew Ballard [aball...@gmail.com]
 Sent: Wednesday, July 21, 2010 11:40 AM
 To: Tim Gallagher
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Question about SQL and Graph nodel trees
 
 On Wed, Jul 21, 2010 at 11:04 AM, Tim Gallagher tgallag...@danati.com
 wrote:
  I cannot be the only one that is having this problem, what are you using for
 DAG (Direct Acrylic Graph)?  I need to have a mesh node edge graph and am
 having trouble with this?  I see that Neo4j has a rest server and I can do 
 this
 in Java but I want to do it in PHP with a MYSQL or postgresql.  If you are 
 doing
 something like this, can you please tell me how you are doing this.  I can do 
 a
 relationship with a parent child or a nested tree, but I need to do a DAG.
 
  Thanks for the help,
  timgerr
 


 
 A basic approach would be to use two tables - one to store the nodes and
 second table to store the edges between the nodes. As far as traversing the
 graph, the best approach I have seen expands this a bit to store the full
 transitive closure of the graph, rather than just the direct edges:
 
 http://www.codeproject.com/KB/database/Modeling_DAGs_on_SQL_DBs.a
 spx
 
 It is written for SQL Server, but the idea works OK (and I successfully 
 tested it
 once) in MySQL. (I imagine the same would be true for PostgreSQL.)
 
 The idea is to store the transitive closure (every possible path) of the 
 entire
 graph. For instance, if you have a basic graph
 
 A - B - C - D
 
 it stores these paths:
 
 A - B
 B - C
 C - D
 A - C
 B - D
 A - D
 
 The obvious downside is that edge table can get incredibly large depending
 on the nature of the graph you are modeling. (The article provides much
 more detail.) I did, however, import a good chunk of an Active Directory tree
 (just users and groups, not the full list of
 attributes) into this pattern just to test the concept, and I found that in 
 that
 case the size of the transitive closure table did not get out of hand.
 
 
 Andrew
 --
 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] Does class length slow down performance

2010-07-22 Thread Sebastian Ewert
Ashley Sheridan wrote:
 On Thu, 2010-07-22 at 10:49 +0200, Sebastian Ewert wrote:
 
 Hi,

 I'm developing an joomla component and my helper an user classes are
 crowing bigger and bigger. The helper class is for static use only.

 Does class size decrease performance of my php scripts, even for static
 usage?
 Is there a general rule when to split a class to keep performance up?

 Thanks for reply,
 Sebastian


 
 
 How big roughly are we talking here? The larger a script or class is,
 the more memory this uses per instance. Out of the box, PHP doesn't have
 a way to share the memory space of libraries and classes, so creating
 massive scripts for a website is not a great idea.
 

The user object contains 850 Lines and about 50 functions. It also
implements 2 table-objects (DB Tables).
The helper class contains 500 Lines.

 The typical approach is to break classes down into blocks such that you
 need only include per script what you actually need to run that script.
 
 For example, having a full class dedicated to user management would need
 somewhere to create a list of users. Now it doesn't make sense to
 include this user management class each time you want to create a list
 of users, so you could split that method off into a different class
 where it can easily be shared without every script loading in lots of
 unnecessary code.

Thats exacty the point. In my user class I have functions whitch return
object-lists of diffrent users or strings with html-form elements for
managing this user account.

But if I put all these in a helper class I would anyway need to
implement the user object there, because of the other getter functions
(getUserName etc.) and the table-objects.

I always thought this would be less effective, because I have more
instances of objects.

Thanks,
Sebastian



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



RE: [PHP] Does class length slow down performance

2010-07-22 Thread Jay Blanchard
[snip]
Thats exacty the point. In my user class I have functions whitch return
object-lists of diffrent users or strings with html-form elements for
managing this user account.

But if I put all these in a helper class I would anyway need to
implement the user object there, because of the other getter functions
(getUserName etc.) and the table-objects.

I always thought this would be less effective, because I have more
instances of objects.
[/snip]

Sounds like a major refactoring is in order, how reusable is your class?

There is not enough room in this e-mail to cover the basic and
intermediate practices of OO design but it sounds like you may need to
re-think your design. Does this class do one thing and only one thing?
Does it do it really well? 

Just from what I am reading I see that we have a user class
(getUserName) and that class returns lists of users? It sounds as if to
me that the user class talks not only about a single user, but perhaps
all of the users (object lists of different users). 

On the surface that sounds like to classes to me, a user class and a
class to manipulate said users.



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



Re: [PHP] Does class length slow down performance

2010-07-22 Thread Sebastian Ewert
Jay Blanchard wrote:
 [snip]
 Thats exacty the point. In my user class I have functions whitch return
 object-lists of diffrent users or strings with html-form elements for
 managing this user account.
 
 But if I put all these in a helper class I would anyway need to
 implement the user object there, because of the other getter functions
 (getUserName etc.) and the table-objects.
 
 I always thought this would be less effective, because I have more
 instances of objects.
 [/snip]
 
 Sounds like a major refactoring is in order, how reusable is your class?
 
 There is not enough room in this e-mail to cover the basic and
 intermediate practices of OO design but it sounds like you may need to
 re-think your design. Does this class do one thing and only one thing?
 Does it do it really well? 
 

Thanks for your advice. I know that I have to go much deeper into
programm design. I would appreciate if you could send me some links with
practial examples. I've only read some theoretical and very general
stuff about it and cannot link everything to the real world.

 Just from what I am reading I see that we have a user class
 (getUserName) and that class returns lists of users? It sounds as if to
 me that the user class talks not only about a single user, but perhaps
 all of the users (object lists of different users). 
 

That was just to generalize things. My user class only returns
informations for one user. These informations are values of db-fields or
generated html strings.

But other classes like my message class have functions that return lists
of instances of their own class. From what you've written I think its
better to extract these functions into helper classes.

But if you want to get all messages that refer to one specific msg its
better to leave that function in the message class, isn't it? Or if you
want to get a list with all friends of a specific user?(friends are not
implemented yet)

 On the surface that sounds like to classes to me, a user class and a
 class to manipulate said users.
 
 

But back to my first Problem:

Is a class with 850 lines to long?
If it is should I take all the html genarating functions and put them in
a helper class?
If I do so and there is no way to call those functions without
initalizing the main user object, will there still be an increase of
performance?

Thanks,
Sebastian


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



[PHP] PHP database interface layer

2010-07-22 Thread Marc Guay
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();

?

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



Re: [PHP] Does class length slow down performance

2010-07-22 Thread Peter Lind
On 22 July 2010 15:27, Sebastian Ewert seb2...@yahoo.de wrote:
 Jay Blanchard wrote:
 [snip]
 Thats exacty the point. In my user class I have functions whitch return
 object-lists of diffrent users or strings with html-form elements for
 managing this user account.

 But if I put all these in a helper class I would anyway need to
 implement the user object there, because of the other getter functions
 (getUserName etc.) and the table-objects.

 I always thought this would be less effective, because I have more
 instances of objects.
 [/snip]

 Sounds like a major refactoring is in order, how reusable is your class?

 There is not enough room in this e-mail to cover the basic and
 intermediate practices of OO design but it sounds like you may need to
 re-think your design. Does this class do one thing and only one thing?
 Does it do it really well?


 Thanks for your advice. I know that I have to go much deeper into
 programm design. I would appreciate if you could send me some links with
 practial examples. I've only read some theoretical and very general
 stuff about it and cannot link everything to the real world.

 Just from what I am reading I see that we have a user class
 (getUserName) and that class returns lists of users? It sounds as if to
 me that the user class talks not only about a single user, but perhaps
 all of the users (object lists of different users).


 That was just to generalize things. My user class only returns
 informations for one user. These informations are values of db-fields or
 generated html strings.

 But other classes like my message class have functions that return lists
 of instances of their own class. From what you've written I think its
 better to extract these functions into helper classes.

 But if you want to get all messages that refer to one specific msg its
 better to leave that function in the message class, isn't it? Or if you
 want to get a list with all friends of a specific user?(friends are not
 implemented yet)

 On the surface that sounds like to classes to me, a user class and a
 class to manipulate said users.



 But back to my first Problem:

 Is a class with 850 lines to long?
 If it is should I take all the html genarating functions and put them in
 a helper class?
 If I do so and there is no way to call those functions without
 initalizing the main user object, will there still be an increase of
 performance?


It's unlikely to cause you performance problems unless you've got a
huge amount of traffic - and then you could probably fix your problems
easier than refactoring classes.

Personal anecdote: I've worked on classes longer than 3K lines with no
marked performance problem. That doesn't mean I recommend it, though:
bigger classes are a pain to maintain as you loose overview of what's
in the class.

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

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



Re: [PHP] PHP database interface layer

2010-07-22 Thread Peter Lind
On 22 July 2010 15:35, Marc Guay marc.g...@gmail.com 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();

 ?


Have you looked at things like 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

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



Re: [PHP] Does class length slow down performance

2010-07-22 Thread Sebastian Ewert
Peter Lind wrote:
 
 It's unlikely to cause you performance problems unless you've got a
 huge amount of traffic - and then you could probably fix your problems
 easier than refactoring classes.
 
 Personal anecdote: I've worked on classes longer than 3K lines with no
 marked performance problem. That doesn't mean I recommend it, though:
 bigger classes are a pain to maintain as you loose overview of what's
 in the class.
 
 Regards
 Peter
 
So you think that a length of 850 lines won't lead to a performance
problem?

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.

Thanks,
Sebastian


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



Re: [PHP] Does class length slow down performance

2010-07-22 Thread Peter Lind
On 22 July 2010 15:49, Sebastian Ewert seb2...@yahoo.de wrote:
 Peter Lind wrote:

 It's unlikely to cause you performance problems unless you've got a
 huge amount of traffic - and then you could probably fix your problems
 easier than refactoring classes.

 Personal anecdote: I've worked on classes longer than 3K lines with no
 marked performance problem. That doesn't mean I recommend it, though:
 bigger classes are a pain to maintain as you loose overview of what's
 in the class.

 Regards
 Peter

 So you think that a length of 850 lines won't lead to a performance
 problem?

 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.

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.

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

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



[PHP] Video lessons

2010-07-22 Thread Jordan Jovanov

Hello

Im thing that I'm little layse, Do you somebody know PHP VIDEO LESSONS?

Thanks a lot.

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



Re: [PHP] PHP database interface layer

2010-07-22 Thread Nathan Nobbe
On Thu, Jul 22, 2010 at 7:35 AM, Marc Guay marc.g...@gmail.com 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();

 ?


i recommend propel

http://www.propelorm.org/

-nathan


Re: [PHP] PHP database interface layer

2010-07-22 Thread Marc Guay
 i recommend propel
 http://www.propelorm.org/

This looks hopeful.  I'd checked it out before but for some reason
lumped it in with all of the other half-baked tools that didn't do
what I wanted, but even that basic example seems to cover most of what
I want.

Thanks for the suggestions.

Marc

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



[PHP] session.gc_ : maxlifetime vs probability/divisor : which has higher priority?

2010-07-22 Thread Keith
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. 



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



RE: [PHP] Does class length slow down performance

2010-07-22 Thread Jay Blanchard
[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.


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



Re: [PHP] Does class length slow down performance

2010-07-22 Thread Sebastian Ewert
 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


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



Re: [PHP] Does class length slow down performance

2010-07-22 Thread David Harkness
On Thu, Jul 22, 2010 at 2:40 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 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


Re: [PHP] PHP database interface layer

2010-07-22 Thread Marc Guay
 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

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



Re: [PHP] PHP database interface layer

2010-07-22 Thread Floyd Resler

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


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



Re: [PHP] PHP database interface layer

2010-07-22 Thread Nathan Nobbe
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


Re: [PHP] PHP database interface layer

2010-07-22 Thread Peter Lind
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

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



Re: [PHP] PHP database interface layer

2010-07-22 Thread Marc Guay
 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

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



[PHP] SOAP ERROR - Encoding

2010-07-22 Thread Augusto Flavio
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


[PHP] Re: PHP database interface layer

2010-07-22 Thread Shawn McKenzie
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

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



[PHP] opening link in new window

2010-07-22 Thread David Mehler
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.

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