[PHP] OOP to run sequential SQL queries?

2013-02-17 Thread AmirBehzad Eslami
Dear list,

We have a bunch of SQL-queries, they should be executed in
a sequential order, with a defensive programming style in mind.

We were thinking to implement the solution as Stored Procedures
instead of a PHP solution that runs SQL queries, but an article in
Coding Horro recommendeds to avoid SP for good reasons:

http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html

Now we're going to carry on in PHP, and my experience says that
we should write the solution in a procedural-style, instead of OOP.

Is there any benefit to use OOP in these situations?

Please share your thoughts.

Thanks,
-behzad


Re: [PHP] OOP to run sequential SQL queries?

2013-02-17 Thread Marco Behnke
Am 17.02.13 17:00, schrieb AmirBehzad Eslami:
 Dear list,

 We have a bunch of SQL-queries, they should be executed in
 a sequential order, with a defensive programming style in mind.
I don't understand what you want?
Queries are executed sequentially or do you plan to create a
multi-process PHP application?

 We were thinking to implement the solution as Stored Procedures
 instead of a PHP solution that runs SQL queries, but an article in
 Coding Horro recommendeds to avoid SP for good reasons:

 http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html

 Now we're going to carry on in PHP, and my experience says that
 we should write the solution in a procedural-style, instead of OOP.

 Is there any benefit to use OOP in these situations?

 Please share your thoughts.

 Thanks,
 -behzad



-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz




signature.asc
Description: OpenPGP digital signature


Re: [PHP] OOP to run sequential SQL queries?

2013-02-17 Thread Serge Fonville
Hi,

We were thinking to implement the solution as Stored Procedures
 instead of a PHP solution that runs SQL queries, but an article in
 Coding Horro recommendeds to avoid SP for good reasons:


The article shows only one thing. that common practice should be to 'do
everything where it belongs'

If you implement this practice within your application, it becomes more
maintainable, more performant and easier to develop.

Also, to determine the styles used to write your code, is almost entirely
dependent on a few things:
* Programmer's preference
* The problem you are solving
* The standards that are commonly used in the environment you are in

Is there any benefit to use OOP in these situations?

Benefits of OOP are that it becomes easier to implement a more standardized
code structure, better match with reality, clearer code, more structure,
re-usability, and a modular design.
These can all be done in procedural code as well, the difference being you
need a different mind- and skillset.

HTH

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table


2013/2/17 Marco Behnke ma...@behnke.biz

 Am 17.02.13 17:00, schrieb AmirBehzad Eslami:
  Dear list,
 
  We have a bunch of SQL-queries, they should be executed in
  a sequential order, with a defensive programming style in mind.
 I don't understand what you want?
 Queries are executed sequentially or do you plan to create a
 multi-process PHP application?
 
  We were thinking to implement the solution as Stored Procedures
  instead of a PHP solution that runs SQL queries, but an article in
  Coding Horro recommendeds to avoid SP for good reasons:
 
 
 http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html
 
  Now we're going to carry on in PHP, and my experience says that
  we should write the solution in a procedural-style, instead of OOP.
 
  Is there any benefit to use OOP in these situations?
 
  Please share your thoughts.
 
  Thanks,
  -behzad
 


 --
 Marco Behnke
 Dipl. Informatiker (FH), SAE Audio Engineer Diploma
 Zend Certified Engineer PHP 5.3

 Tel.: 0174 / 9722336
 e-Mail: ma...@behnke.biz

 Softwaretechnik Behnke
 Heinrich-Heine-Str. 7D
 21218 Seevetal

 http://www.behnke.biz





Re: [PHP] OOP to run sequential SQL queries?

2013-02-17 Thread tamouse mailing lists
On Sun, Feb 17, 2013 at 10:00 AM, AmirBehzad Eslami
behzad.esl...@gmail.com wrote:
 We have a bunch of SQL-queries, they should be executed in
 a sequential order, with a defensive programming style in mind.

 We were thinking to implement the solution as Stored Procedures
 instead of a PHP solution that runs SQL queries, but an article in
 Coding Horro recommendeds to avoid SP for good reasons:

 http://www.codinghorror.com/blog/2004/10/who-needs-stored-procedures-anyways.html

As has been said, everything has it's place, every tool has it's use,
but we've all used that screwdriver to both open a can of paint and
then bang on the lid with handle to get it closed again. Meaning that
just because there's a tool to hand, it doesn't always mean it's the
right thing.

I tend to use stored procs when what I need to get accomplished
resides well within the database and utilizes the database engine more
effectively, and when such activities might become I/O bandwidth
issues if it were all done serially within the application. In other
words, very few and far between.

If the dataset is large and involves some very complex queries (lots
of nested selects and so on), it is often better as a stored proc. But
there is a caveat there as well in that often times the skill sets for
maintaining complex SQL code can be a lot harder to find and acquire
than the skill set for maintaining the same logic in PHP.

So, no absolutes, one way or another.

 Now we're going to carry on in PHP, and my experience says that
 we should write the solution in a procedural-style, instead of OOP.

 Is there any benefit to use OOP in these situations?

 Please share your thoughts.

This is actually a very similar question: again, no absolutes. An OO
approach is well fit for some aspects of implementation, and a
procedural approach to others, and then there is the functional
approach, which is yet another way of looking at the problem. Even
with that, all three can come into play in any given application. What
is to be gained by using an object approach, versus procedural, versus
functional? If it's a fairly confined operation, perhaps wrapping it
in an object might give some more portability, and if the rest of the
application utilizes an object approach, would be a good way to go.

If the rest of the application is primarily procedural, then
introducing an object approach might become more of a maintenance
issue.

So, really, it's not a simple answer. There are far too many considerations.

Other things to consider: does the entire series of queries need to be
performed in a locked state, i.e., if the database records change
during the series of queries, will things break? This has very huge
performance considerations, and should be taken into account. One of
the purported uses of stored procs is that it's easier to implement an
atomic operation such as that, but that's really not entirely accurate
either. It's quite possible to lock and release while still running
the queries sequentially from code. The round-trip factors of I/O do
weigh more heavily here.

My overall suggestion: Do it the simplest way you can right now,
measure, charaacterize, look at how the whole app operates, and
refactor what needs to be refactored when you have some actual
performance data.

Recognize also that simplest is pretty subjective based upon you and
your fellow devs experiences and points of view. A super DBA person
might be able to snap off a stored proc in no time; while an
experience PHPer might be able to do the same procedurally. It doesn't
mean either one is better than the other. Only putting it into play
and actually measuring it will do that.

Stumbling over how best to do something is very often less optimal
than just implementing and seeing for yourself.

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



[PHP] OOP problems

2011-12-15 Thread Dominik Halvoník
Hello,

I would like to ask you for help. This days I am trying to build one of my
applications. But I have problem which stopped me. I have folder whit php
files like connect.php, delete.php etc. These files contains classes named
the same as files. So in file connect.php is class Connect. These files are
placed in folder named mysql and this folder is inside folder named db. In
folder db is a php file named mysql.php, in this file I include classes
from folder mysql, after include I declare class MySQL and in it I have
method __construct(). In this method I create dynamic objects from included
classes. And this is the problem that I can not solve, I have more then one
of this files(mysql.php[whit class MySQL], oracle.php[whit class Oracle]
etc.) and I need to include them to file called db.php that is in the main
folder of my app. In db.php is an class called db, how can I add classes
MySQL, Oracle etc. to class db? I try to use abstract class whit __set and
__get methods but I also need to include class db to main class
application. I am really sorry for my English, so please be indulgent. So I
need to connect classes like this:

application-db-mysql-connect, but I can not use extends because in php
you can have only one parent class. The reason why I am trying to do
something like this is because I want to call methods like this:
$test = new application();
$test-db-connect();

If it is mysql or othet database I set in config.php file.

I need to achieve this schema( - is something like ../ it means that it is
one level up folder):

connec.php(class Connect MySql)-
select.php(class Select MySql) -
 - mysql.php(class MySQL include all classes, Connect...)-
 -
... -
- db.php(class db include all classes, MySQL, Oracle..)
connec.php(class Connect Oracle)-
select.php(class Select Oracle ) -
 - oracle .php(class Oracle include all classes, Connect...)-
 -
... -

download.php(class Download)-
unzip.php(class Unzip) -
 - files.php(class Files include all classes, Download...) -
file.php(class file include class Files)
 -
... -

hash.php(class Hash)-
capcha.php(class Capcha) -
 - secure.php(class Secure include all classes, Hash...) -
security.php(class security include class Secure)
 -
... -
ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect.

And in the end, in the same folder as db.php and security.php I will have
file application.php which will contain class application and in its
__construct() method I will make link classes db, security, file ect. ect.
So I will just include file application.php make object from class
application and then just do $object-db-connect()(of course if it will by
MySql or other database will be stored in some config.php file).

Thanks,

Dominik


Re: [PHP] OOP problems

2011-12-15 Thread Alex Pojarsky
I'm not sure I've understood you correctly, but you may try something
like the following primitive autoloader (I didn't debug it, it's just
an example):

class Base
{
protected $_path = '';

public function construct($base_path)
{
$this-_path = $base_path;
}
public function __get($name)
{
$requested_path = $this-_path . DIRECTORY_SEPARATOR . $name;
if (is_dir($requested_path))
{
return new Base($requested_path);
}
else if (is_file($requested_path . '.php'))
{
include ($requested_path . '.php');
$classname = ucfirst($name);
return new $clasname();
}
}
}

// Assuming you have Mysql class in /home/user/project/classes/db/mysql.php
// you may try

$base = new Base(/home/user/project/classes/);
$base-db-mysql-someFunctionOfMysqlClass();

2011/12/15 Dominik Halvoník dominik.halvo...@gmail.com:
 Hello,

 I would like to ask you for help. This days I am trying to build one of my
 applications. But I have problem which stopped me. I have folder whit php
 files like connect.php, delete.php etc. These files contains classes named
 the same as files. So in file connect.php is class Connect. These files are
 placed in folder named mysql and this folder is inside folder named db. In
 folder db is a php file named mysql.php, in this file I include classes
 from folder mysql, after include I declare class MySQL and in it I have
 method __construct(). In this method I create dynamic objects from included
 classes. And this is the problem that I can not solve, I have more then one
 of this files(mysql.php[whit class MySQL], oracle.php[whit class Oracle]
 etc.) and I need to include them to file called db.php that is in the main
 folder of my app. In db.php is an class called db, how can I add classes
 MySQL, Oracle etc. to class db? I try to use abstract class whit __set and
 __get methods but I also need to include class db to main class
 application. I am really sorry for my English, so please be indulgent. So I
 need to connect classes like this:

 application-db-mysql-connect, but I can not use extends because in php
 you can have only one parent class. The reason why I am trying to do
 something like this is because I want to call methods like this:
 $test = new application();
 $test-db-connect();

 If it is mysql or othet database I set in config.php file.

 I need to achieve this schema( - is something like ../ it means that it is
 one level up folder):

 connec.php(class Connect MySql)-
 select.php(class Select MySql) -
  - mysql.php(class MySQL include all classes, Connect...)-
  -
 ... -
 - db.php(class db include all classes, MySQL, Oracle..)
 connec.php(class Connect Oracle)-
 select.php(class Select Oracle ) -
  - oracle .php(class Oracle include all classes, Connect...)-
  -
 ... -

 download.php(class Download)-
 unzip.php(class Unzip) -
  - files.php(class Files include all classes, Download...) -
 file.php(class file include class Files)
  -
 ... -

 hash.php(class Hash)-
 capcha.php(class Capcha) -
  - secure.php(class Secure include all classes, Hash...) -
 security.php(class security include class Secure)
  -
 ... -
 ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect.

 And in the end, in the same folder as db.php and security.php I will have
 file application.php which will contain class application and in its
 __construct() method I will make link classes db, security, file ect. ect.
 So I will just include file application.php make object from class
 application and then just do $object-db-connect()(of course if it will by
 MySql or other database will be stored in some config.php file).

 Thanks,

 Dominik

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



Re: [PHP] OOP problems

2011-12-15 Thread Fatih P.


On 12/15/2011 01:05 PM, Alex Pojarsky wrote:

I'm not sure I've understood you correctly, but you may try something
like the following primitive autoloader (I didn't debug it, it's just
an example):

class Base
{
 protected $_path = '';

 public function construct($base_path)
 {
 $this-_path = $base_path;
 }
 public function __get($name)
 {
 $requested_path = $this-_path . DIRECTORY_SEPARATOR . $name;
 if (is_dir($requested_path))
 {
 return new Base($requested_path);
 }
 else if (is_file($requested_path . '.php'))
 {
 include ($requested_path . '.php');
 $classname = ucfirst($name);
 return new $clasname();
 }
 }
}

// Assuming you have Mysql class in /home/user/project/classes/db/mysql.php
// you may try

$base = new Base(/home/user/project/classes/);
$base-db-mysql-someFunctionOfMysqlClass();

2011/12/15 Dominik Halvoníkdominik.halvo...@gmail.com:

Hello,

I would like to ask you for help. This days I am trying to build one of my
applications. But I have problem which stopped me. I have folder whit php
files like connect.php, delete.php etc. These files contains classes named
the same as files. So in file connect.php is class Connect. These files are
placed in folder named mysql and this folder is inside folder named db. In
folder db is a php file named mysql.php, in this file I include classes
from folder mysql, after include I declare class MySQL and in it I have
method __construct(). In this method I create dynamic objects from included
classes. And this is the problem that I can not solve, I have more then one
of this files(mysql.php[whit class MySQL], oracle.php[whit class Oracle]
etc.) and I need to include them to file called db.php that is in the main
folder of my app. In db.php is an class called db, how can I add classes
MySQL, Oracle etc. to class db? I try to use abstract class whit __set and
__get methods but I also need to include class db to main class
application. I am really sorry for my English, so please be indulgent. So I
need to connect classes like this:

application-db-mysql-connect, but I can not use extends because in php
you can have only one parent class. The reason why I am trying to do
something like this is because I want to call methods like this:
$test = new application();
$test-db-connect();

If it is mysql or othet database I set in config.php file.

I need to achieve this schema( -  is something like ../ it means that it is
one level up folder):

connec.php(class Connect MySql)-
select.php(class Select MySql) -
 -  mysql.php(class MySQL include all classes, Connect...)-
 -
... -
-  db.php(class db include all classes, MySQL, Oracle..)
connec.php(class Connect Oracle)-
select.php(class Select Oracle ) -
 -  oracle .php(class Oracle include all classes, Connect...)-
 -
... -

download.php(class Download)-
unzip.php(class Unzip) -
 -  files.php(class Files include all classes, Download...) -
file.php(class file include class Files)
 -
... -

hash.php(class Hash)-
capcha.php(class Capcha) -
 -  secure.php(class Secure include all classes, Hash...) -
security.php(class security include class Secure)
 -
... -
ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect.

And in the end, in the same folder as db.php and security.php I will have
file application.php which will contain class application and in its
__construct() method I will make link classes db, security, file ect. ect.
So I will just include file application.php make object from class
application and then just do $object-db-connect()(of course if it will by
MySql or other database will be stored in some config.php file).

Thanks,

Dominik

Why don't you modify include_path on initialization of 'Base' class?

would make things much simpler.

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



Re: [PHP] OOP problems

2011-12-11 Thread Dominik Halvoník
Hi guys,

I try to applied your solutions but I have problems whit it. I need to
achieve this schema( -  is something like ../ it means that it is one
level up folder):

connec.php(class Connect MySql)-
select.php(class Select MySql) -
 - mysql.php(class MySQL
include all classes, Connect...)-
 -
...  -

  -
db.php(class db include all classes, MySQL, Oracle..)
 connec.php(class Connect Oracle)-
select.php(class Select Oracle ) -
 -  oracle .php(class
Oracle include all classes, Connect...)-
 -
...  -

download.php(class Download)-
unzip.php(class Unzip) -
 - files.php(class Files
include all classes, Download...) - file.php(class file include class
Files)
 -
...  -

hash.php(class Hash)-
capcha.php(class Capcha) -
 - secure.php(class Secure
include all classes, Hash...) - security.php(class security include class
Secure)
 -
...  -
*ect. ect. ect.  ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect. ect.
*

And in the end, in the same folder as db.php and security.php I will have
file application.php which will contain class application and in its
__construct() method I will make link classes db, security, file ect. ect.
So I will just include file application.php make object from class
application and then just do $object-db-connect()(of course if it will by
MySql or other database will be stored in some config.php file).

Thanks,

Dominik


[PHP] OOP problems

2011-12-08 Thread Dominik Halvoník
Hello,

I would like to ask you for help. This days I am trying to build one of my
applications. But I have problem which stopped me. I have folder whit php
files like connect.php, delete.php etc. These files contains classes named
the same as files. So in file connect.php is class Connect. These files are
placed in folder named mysql and this folder is inside folder named db. In
folder db is a php file named mysql.php, in this file I include classes
from folder mysql, after include I declare class MySQL and in it I have
method __construct(). In this method I create dynamic objects from included
classes. And this is the problem that I can not solve, I have more then one
of this files(mysql.php[whit class MySQL], oracle.php[whit class Oracle]
etc.) and I need to include them to file called db.php that is in the main
folder of my app. In db.php is an class called db, how can I add classes
MySQL, Oracle etc. to class db? I try to use abstract class whit __set and
__get methods but I also need to include class db to main class
application. I am really sorry for my English, so please be indulgent. So I
need to connect classes like this:

application-db-mysql-connect, but I can not use extends because in php
you can have only one parent class. The reason why I am trying to do
something like this is because I want to call methods like this:
$test = new application();
$test-db-connect();

If it is mysql or othet database I set in config.php file. Can you help my
please?

Sincerely,

Dominik Halvonik


Re: [PHP] OOP problems

2011-12-08 Thread Stuart Dallas
On 8 Dec 2011, at 17:14, Dominik Halvoník wrote:

 I would like to ask you for help. This days I am trying to build one of my
 applications. But I have problem which stopped me. I have folder whit php
 files like connect.php, delete.php etc. These files contains classes named
 the same as files. So in file connect.php is class Connect. These files are
 placed in folder named mysql and this folder is inside folder named db. In
 folder db is a php file named mysql.php, in this file I include classes
 from folder mysql, after include I declare class MySQL and in it I have
 method __construct(). In this method I create dynamic objects from included
 classes. And this is the problem that I can not solve, I have more then one
 of this files(mysql.php[whit class MySQL], oracle.php[whit class Oracle]
 etc.) and I need to include them to file called db.php that is in the main
 folder of my app. In db.php is an class called db, how can I add classes
 MySQL, Oracle etc. to class db? I try to use abstract class whit __set and
 __get methods but I also need to include class db to main class
 application. I am really sorry for my English, so please be indulgent. So I
 need to connect classes like this:
 
 application-db-mysql-connect, but I can not use extends because in php
 you can have only one parent class. The reason why I am trying to do
 something like this is because I want to call methods like this:
 $test = new application();
 $test-db-connect();
 
 If it is mysql or othet database I set in config.php file. Can you help my
 please?


You don't say what the db class (in db.php) itself does other than wrapping the 
database-specific classes, so I've assumed it doesn't do anything. If it does 
do more then simply have the mysql, oracle, etc classes extend db.

I've also assumed that the application doesn't need to support multiple 
database types simultaneously.

class application
{
  public $db = null;

  function __construct($db = 'mysql')
  {
require __DIR__.'/db/'.$db.'.php';
$this-db = new MySQL();
  }
}

$test = new application('mysql');
$test-db-connect();

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] OOP problems

2011-12-08 Thread Mokaddim Akm
Sent from a handheld device

On 08-Dec-2011, at 11:14 PM, Dominik Halvoník
dominik.halvo...@gmail.com wrote:

 Hello,

 I would like to ask you for help. This days I am trying to build one of my
 applications. But I have problem which stopped me. I have folder whit php
 files like connect.php, delete.php etc. These files contains classes named
 the same as files. So in file connect.php is class Connect. These files are
 placed in folder named mysql and this folder is inside folder named db. In
 folder db is a php file named mysql.php, in this file I include classes
 from folder mysql, after include I declare class MySQL and in it I have
 method __construct(). In this method I create dynamic objects from included
 classes. And this is the problem that I can not solve, I have more then one
 of this files(mysql.php[whit class MySQL], oracle.php[whit class Oracle]
 etc.) and I need to include them to file called db.php that is in the main
 folder of my app. In db.php is an class called db, how can I add classes
 MySQL, Oracle etc. to class db? I try to use abstract class whit __set and
 __get methods but I also need to include class db to main class
 application. I am really sorry for my English, so please be indulgent. So I
 need to connect classes like this:


This is where common design patters comes handy.
Your problem can be solved by factory pattern.
Create a static method connect on db class. Then call it like
$db = DB::connect($db_type)

Here the db type variable contains MySQL or oracle. In connect static
method you implement the logic on how to connect that specific
database. In the connect method you can also take db credentials like
username and password.

Google php design pattern to know more.


 application-db-mysql-connect, but I can not use extends because in php
 you can have only one parent class. The reason why I am trying to do
 something like this is because I want to call methods like this:
 $test = new application();
 $test-db-connect();

 If it is mysql or othet database I set in config.php file. Can you help my
 please?

 Sincerely,

 Dominik Halvonik

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



[PHP] OOP Design Question

2009-12-20 Thread Daniel Kolbo
Hello PHPers,

I have a collection of about 60 objects (class definitions).  They are
all very similar.  They all share a substantial % of the same core.  But
they all have slight variations as well.  The approach I took was to
make an abstract core class, and each of the 60 objects extends that
core.  This works, but...

Here's my problem, not every php/http request requires all 60 objects.
At this point, I do not know in advance which objects will be required,
so i include the class def of all 60 objects every time...  I don't like
this idea as it seems a 'bloated' approach.

So now i'm thinking instead i'll just have one object which has the
union of all the 60 objects' methods.  But i'm not too happy with this
either b/c (i) now each instantiated object is carrying around a lot of
unneccessary baggage, (ii) i lose modularity of code, and (iii) the code
does not make as much 'intuitive' sense.  For (iii), 'why does this
object have this method?' type questions another programmer would ask
(or me a year from now).  The answer would be 'efficiency concerns',
which i'm aware that you generally don't want to compromise code
readability for efficiency if avoidable.

Maybe this would be the perfect opportunity for the php autoload
functions...?

Thanks for your help/thoughts/comments,
dK
`

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



Re: [PHP] OOP Design Question

2009-12-20 Thread Robert Cummings

Set up autoloading:

http://php.net/manual/en/language.oop5.autoload.php

Cheers,
Rob.


Daniel Kolbo wrote:

Hello PHPers,

I have a collection of about 60 objects (class definitions).  They are
all very similar.  They all share a substantial % of the same core.  But
they all have slight variations as well.  The approach I took was to
make an abstract core class, and each of the 60 objects extends that
core.  This works, but...

Here's my problem, not every php/http request requires all 60 objects.
At this point, I do not know in advance which objects will be required,
so i include the class def of all 60 objects every time...  I don't like
this idea as it seems a 'bloated' approach.

So now i'm thinking instead i'll just have one object which has the
union of all the 60 objects' methods.  But i'm not too happy with this
either b/c (i) now each instantiated object is carrying around a lot of
unneccessary baggage, (ii) i lose modularity of code, and (iii) the code
does not make as much 'intuitive' sense.  For (iii), 'why does this
object have this method?' type questions another programmer would ask
(or me a year from now).  The answer would be 'efficiency concerns',
which i'm aware that you generally don't want to compromise code
readability for efficiency if avoidable.

Maybe this would be the perfect opportunity for the php autoload
functions...?

Thanks for your help/thoughts/comments,
dK
`



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

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



Re: [PHP] OOP Design Question

2009-12-20 Thread Larry Garfield
On Sunday 20 December 2009 10:35:56 am Daniel Kolbo wrote:
 Hello PHPers,

 I have a collection of about 60 objects (class definitions).  They are
 all very similar.  They all share a substantial % of the same core.  But
 they all have slight variations as well.  The approach I took was to
 make an abstract core class, and each of the 60 objects extends that
 core.  This works, but...

 Here's my problem, not every php/http request requires all 60 objects.
 At this point, I do not know in advance which objects will be required,
 so i include the class def of all 60 objects every time...  I don't like
 this idea as it seems a 'bloated' approach.

 So now i'm thinking instead i'll just have one object which has the
 union of all the 60 objects' methods.  But i'm not too happy with this
 either b/c (i) now each instantiated object is carrying around a lot of
 unneccessary baggage, (ii) i lose modularity of code, and (iii) the code
 does not make as much 'intuitive' sense.  For (iii), 'why does this
 object have this method?' type questions another programmer would ask
 (or me a year from now).  The answer would be 'efficiency concerns',
 which i'm aware that you generally don't want to compromise code
 readability for efficiency if avoidable.

 Maybe this would be the perfect opportunity for the php autoload
 functions...?

 Thanks for your help/thoughts/comments,
 dK
 `

Yep, this is a textbook case for a proper autoload setup.  And no, cramming 
all of the functionality into one mega class won't get you any efficiency.  In 
fact, it would be just as wasteful as loading all 60 classes even when you're 
only going to use 2; you're still loading up roughly the same amount of code.  
Parsing it as one mega class or one big parent with a few small child classes 
is about a break-even as far as performance goes, but the mega class is much 
poorer architecture.

-- 
Larry Garfield
la...@garfieldtech.com

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



Re: [PHP] OOP Design Question

2009-12-20 Thread Larry Garfield
On Sunday 20 December 2009 1:08:46 pm you wrote:

  Maybe this would be the perfect opportunity for the php autoload
  functions...?
 
  Thanks for your help/thoughts/comments,
  dK
  `
 
  Yep, this is a textbook case for a proper autoload setup.  And no,
  cramming all of the functionality into one mega class won't get you any
  efficiency.  In fact, it would be just as wasteful as loading all 60
  classes even when you're only going to use 2; you're still loading up
  roughly the same amount of code. Parsing it as one mega class or one big
  parent with a few small child classes is about a break-even as far as
  performance goes, but the mega class is much poorer architecture.

 Thanks for your insight.

 I could probably setup autoloading, but I wonder if I would do it
 'properly'.  Do you have a link or reference that you'd recommend for
 howto do a 'proper autoload setup'?

 Thanks,
 dK

Well, there is no universal agreement on what a proper setup is. :-)  There 
is a group trying to establish a Java-like standard for all projects to use 
once they get to PHP 5.3 and namespaces, but there are still issues to work 
out and IMO it's not actually a good approach for many use cases.  I'd argue 
that proper depends in a large part on your specific use case.

The most important aspect of a good autoload mechanism, though, is that it's 
fast and extensible.  Use spl_autoload_register() instead of __autoload(), and 
make sure that you keep the runtime of your autoload callbacks to an absolute 
minimum.  (A DB hit per autoload, for instance, is a no-no.)

Beyond that, varies with your project.

-- 
Larry Garfield
la...@garfieldtech.com

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



[PHP] OOP Design Software

2009-07-26 Thread Daniel Kolbo
Hello,

Is there an objected oriented programming software that can help me keep
track of my methods and properties of my objects.  My memory is not what
it used to be, and i'd like to have a quick 'overview' or layout of all
the objects I have to work with.  Maybe the software would even let make
a process flow chart.  This would really help my design (and save me time).

Thanks,
dK
`

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



RE: [PHP] OOP Design Software

2009-07-26 Thread Caner BULUT

Hi Daniel,

You can use Eclipse with plugin PDT or Zend Studio. They can track your
classes and methods. They can remember your methods and classes also they
have code completion abilities.

Thanks
Caner.

-Original Message-
From: Daniel Kolbo [mailto:kolb0...@umn.edu] 
Sent: 26 July 2009 19:46
To: PHP General
Subject: [PHP] OOP Design Software

Hello,

Is there an objected oriented programming software that can help me keep
track of my methods and properties of my objects.  My memory is not what
it used to be, and i'd like to have a quick 'overview' or layout of all
the objects I have to work with.  Maybe the software would even let make
a process flow chart.  This would really help my design (and save me time).

Thanks,
dK
`

-- 
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] OOP Design Software

2009-07-26 Thread Eddie Drapkin
On Sun, Jul 26, 2009 at 12:54 PM, Caner BULUTcaner...@gmail.com wrote:

 Hi Daniel,

 You can use Eclipse with plugin PDT or Zend Studio. They can track your
 classes and methods. They can remember your methods and classes also they
 have code completion abilities.

 Thanks
 Caner.

 -Original Message-
 From: Daniel Kolbo [mailto:kolb0...@umn.edu]
 Sent: 26 July 2009 19:46
 To: PHP General
 Subject: [PHP] OOP Design Software

 Hello,

 Is there an objected oriented programming software that can help me keep
 track of my methods and properties of my objects.  My memory is not what
 it used to be, and i'd like to have a quick 'overview' or layout of all
 the objects I have to work with.  Maybe the software would even let make
 a process flow chart.  This would really help my design (and save me time).

 Thanks,
 dK
 `

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



There's plugins for Eclipse that generate UML, too.

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



Re: [PHP] OOP Design Software

2009-07-26 Thread Daniel Kolbo


Caner BULUT wrote:
 Hi Daniel,
 
 You can use Eclipse with plugin PDT or Zend Studio. They can track your
 classes and methods. They can remember your methods and classes also they
 have code completion abilities.
 
 Thanks
 Caner.
 
 -Original Message-
 From: Daniel Kolbo [mailto:kolb0...@umn.edu] 
 Sent: 26 July 2009 19:46
 To: PHP General
 Subject: [PHP] OOP Design Software
 
 Hello,
 
 Is there an objected oriented programming software that can help me keep
 track of my methods and properties of my objects.  My memory is not what
 it used to be, and i'd like to have a quick 'overview' or layout of all
 the objects I have to work with.  Maybe the software would even let make
 a process flow chart.  This would really help my design (and save me time).
 
 Thanks,
 dK
 `
 
Wow.  Thanks for the reference.  I've been playing with EclipsePDT for
about 30-45 minutes.  I've been developing strictly off of a text editor
(with some syntax coloring but that's it).  This Eclipse project looks
so big.  There'll be a bit of a learning curve with the EclipsePDT but
seeing that it was developed in part by Zend and also that smarty.net
uses it, i can rest assured that my time learning/implementing eclipse
will save me a great deal of time in the long haul.  I am glad to see it
has integration with xdebug and CVS.  I'll have to postpone my weekend
coding goals to learn Eclipse and see how to integrate it into my
development process.  Thanks for the recommendation (and quick too).
Thanks,
dK
`

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



[PHP] PHP, OOP and AJAX

2009-06-05 Thread Julian Muscat Doublesin
Update.

Hello Everyone,

First of all, thank you all for your input. I ran a sinmple test using the
suggestions you gave me and and require_once.

Using firebug to test the output, I got an internal server error. I found
out what the problem was.

What I am doing is I have  classes which represent the objects, another
class containing the functions. From the function class I create an instance
of each object, manipulate the information, return the HTML result. Finally
I have a runner class that creates an instance of the function class, calls
the function required and outputs the information.

What the problem was for some reason I was did not create an instance of the
function class, just was calling the function. Well by creating the runner
class I solved the problem.

Thanks all for your help.

Regards

Julian


[PHP] PHP, OOP and AJAX

2009-05-28 Thread Julian Muscat Doublesin
Hi Everyone,

This is the first time that I am posting in the PHP forum, so hope that I am
osting in the right place.

I would like to say that before submitting to this forum I have done some
research looking for a solution without success.

I had been programming in ASP.NET for years using Object Oriented
Princeliness but decided to walk away from that.  I am now researching and
specialising in the open source world.

I have started to develop a project using MySQL, PHP and OOP. So far I have
succeed. However I got stuck once I started implement AJAX using the AJAX
tutorial from w3schools.com.

What I have discovered is: for some reason when you call a file that
requires other fies using the REQUIRE or INCLUDE it just does not work. I
can conform this as I have tested with out the the functions.

Has anyone ever meet such a situation can you give me some feedback please.

Thank you very much in advance for your support.

Regards

Julian


[PHP] Re: PHP, OOP and AJAX

2009-05-28 Thread Jo�o C�ndido de Souza Neto
Julian,

could you please show us an example of this problem?


-- 
João Cândido de Souza Neto
SIENS SOLUÇÕES EM GESTÃO DE NEGÓCIOS
Fone: (0XX41) 3033-3636 - JS
www.siens.com.br

Julian Muscat Doublesin opensourc...@gmail.com escreveu na mensagem 
news:5e0039ed0905280431o2e9d8036u217b0449eccd...@mail.gmail.com...
 Hi Everyone,

 This is the first time that I am posting in the PHP forum, so hope that I 
 am
 osting in the right place.

 I would like to say that before submitting to this forum I have done some
 research looking for a solution without success.

 I had been programming in ASP.NET for years using Object Oriented
 Princeliness but decided to walk away from that.  I am now researching and
 specialising in the open source world.

 I have started to develop a project using MySQL, PHP and OOP. So far I 
 have
 succeed. However I got stuck once I started implement AJAX using the AJAX
 tutorial from w3schools.com.

 What I have discovered is: for some reason when you call a file that
 requires other fies using the REQUIRE or INCLUDE it just does not work. I
 can conform this as I have tested with out the the functions.

 Has anyone ever meet such a situation can you give me some feedback 
 please.

 Thank you very much in advance for your support.

 Regards

 Julian
 



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



Re: [PHP] Re: PHP, OOP and AJAX

2009-05-28 Thread kranthi
i never faced such a problem and i can assure you that it will never
happen. try...

main.php
?php
require('second.php');
?

second.php
test

call main.php via AJAX and see the responseText.
many things can go wrong in your coding. dont come to the conclusion
that this particular thing is not working.

i recommend you firebug firefox adddon (just go to the net tab and you
can see all the details of the communication between client and
server)
and i find it helpful to use a standard javascript(jQuery in my case)
library instead of highly limited plain javascript  language

and for you case its difficult to comment without seeing your actual code.

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



Re: Re: [PHP] Re: PHP, OOP and AJAX

2009-05-28 Thread oorza2k5

Two things:

1. Try using the fully qualified path (ie /var/www/foo/bar.php instead of  
foo/bar.php)
2. Look at setting up autoloading so you don't need to manually include  
anyway. If you're going OOP, autoloading is a must!


On May 28, 2009 8:49am, kranthi kranthi...@gmail.com wrote:

i never faced such a problem and i can assure you that it will never



happen. try...





main.php




require('second.php');



?





second.php



test





call main.php via AJAX and see the responseText.



many things can go wrong in your coding. dont come to the conclusion



that this particular thing is not working.





i recommend you firebug firefox adddon (just go to the net tab and you



can see all the details of the communication between client and



server)



and i find it helpful to use a standard javascript(jQuery in my case)



library instead of highly limited plain javascript language





and for you case its difficult to comment without seeing your actual code.





--



PHP General Mailing List (http://www.php.net/)



To unsubscribe, visit: http://www.php.net/unsub.php






Re: [PHP] Re: PHP, OOP and AJAX

2009-05-28 Thread Lenin
2009/5/28 kranthi kranthi...@gmail.com



 i recommend you firebug firefox adddon (just go to the net tab and you
 can see all the details of the communication between client and
 server)
 and i find it helpful to use a standard javascript(jQuery in my case)
 library instead of highly limited plain javascript  language

I also recommend using FirePHP with FireBug here's a nicely written tutorial
on how to use them both together for Ajax'ed pages. http://tr.im/iyvl
Thanks
Lenin
www.twitter.com/nine_L


Re: [PHP] Re: PHP, OOP and AJAX

2009-05-28 Thread Olexandr Heneralov
Hi!
Do not use low-level AJAX.
There are many frameworks for ajax (JQUERY).
Try to use PHP frameworks like symfony, zend framework. They simplify your
work.


2009/5/28 Lenin le...@phpxperts.net

 2009/5/28 kranthi kranthi...@gmail.com

 
 
  i recommend you firebug firefox adddon (just go to the net tab and you
  can see all the details of the communication between client and
  server)
  and i find it helpful to use a standard javascript(jQuery in my case)
  library instead of highly limited plain javascript  language
 
 I also recommend using FirePHP with FireBug here's a nicely written
 tutorial
 on how to use them both together for Ajax'ed pages. http://tr.im/iyvl
 Thanks
 Lenin
 www.twitter.com/nine_L



Re: [PHP] Re: PHP, OOP and AJAX

2009-05-28 Thread Luke
2009/5/28 Olexandr Heneralov ohenera...@gmail.com

 Hi!
 Do not use low-level AJAX.
 There are many frameworks for ajax (JQUERY).
 Try to use PHP frameworks like symfony, zend framework. They simplify your
 work.


 2009/5/28 Lenin le...@phpxperts.net

  2009/5/28 kranthi kranthi...@gmail.com
 
  
  
   i recommend you firebug firefox adddon (just go to the net tab and you
   can see all the details of the communication between client and
   server)
   and i find it helpful to use a standard javascript(jQuery in my case)
   library instead of highly limited plain javascript  language
  
  I also recommend using FirePHP with FireBug here's a nicely written
  tutorial
  on how to use them both together for Ajax'ed pages. http://tr.im/iyvl
  Thanks
  Lenin
  www.twitter.com/nine_L
 



Moo, I would say learn to do PHP by itself before you go using frameworks.

AJAX is a bit different though because there will be few reasons that you
will ever need to write low level code when you're using a library like
Prototype =)

-- 
Luke Slater
:O)


Re: Re: [PHP] Re: PHP, OOP and AJAX

2009-05-28 Thread Tony Marston

oorza...@gmail.com wrote in message 
news:000e0cd6ad1a9f7d3d046af89...@google.com...
 Two things:

 1. Try using the fully qualified path (ie /var/www/foo/bar.php instead of
 foo/bar.php)
 2. Look at setting up autoloading so you don't need to manually include
 anyway. If you're going OOP, autoloading is a must!

I totally disagree. I have been doing OOP with PHP for years, and I have 
never used autoloading. It is just a feature that can be used, misused or 
abused just like any other. I choose not to use it, and my code does not 
suffer in the least!

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org




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



Re: Re: [PHP] Re: PHP, OOP and AJAX

2009-05-28 Thread Tony Marston
Eddie Drapkin oorza...@gmail.com wrote in message 
news:68de37340905280737t3e1ad844y188ab8fa08f17...@mail.gmail.com...
 Your code might not, but you sure do!  Spending all that time writing
 require statements = :(

If you are too lazy to write require statements then you are probably too 
lazy to write readable, well structured and efficient code. Besides, I don't 
use require statements, I use
$dbobject = singleton::getInstance('classname');

I don't use autoload because *I* want to be in control. I prefer not to rely 
on automatuic features which may not work as expected.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

 On Thu, May 28, 2009 at 9:49 AM, Tony Marston 
 t...@marston-home.demon.co.uk
 wrote:


 oorza...@gmail.com wrote in message
 news:000e0cd6ad1a9f7d3d046af89...@google.com...
  Two things:
 
  1. Try using the fully qualified path (ie /var/www/foo/bar.php instead 
  of
  foo/bar.php)
  2. Look at setting up autoloading so you don't need to manually include
  anyway. If you're going OOP, autoloading is a must!

 I totally disagree. I have been doing OOP with PHP for years, and I have
 never used autoloading. It is just a feature that can be used, misused or
 abused just like any other. I choose not to use it, and my code does not
 suffer in the least!

 --
 Tony Marston
 http://www.tonymarston.net
 http://www.radicore.org




 --
 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: Re: [PHP] Re: PHP, OOP and AJAX

2009-05-28 Thread Eddie Drapkin
There's a huge difference between laziness and opting in to use an
incredibly useful (and easy to properly deploy) feature to save myself time
so that I can spend more time writing that structured and efficient code of
which you speak.  And the problem with what you're saying is that you still
have to include 'singleton.php' somewhere in order to call its static
methods, and I'd rather just spend 30 minutes writing an autoloader object
and letting it deal with finding any of the classes I use then trying to
keep track of legacy code I didn't write and require'ing them all over the
place.

The way I look at it, if you spend all your time handling things that you
could automate - and if written properly, will always work as expected (it's
called unit testing and debugging) - then you have no time to write that
structured and efficient code in order to meet your deadlines! :)

On Thu, May 28, 2009 at 10:53 AM, Tony Marston 
t...@marston-home.demon.co.uk wrote:

 Eddie Drapkin oorza...@gmail.com wrote in message
 news:68de37340905280737t3e1ad844y188ab8fa08f17...@mail.gmail.com...
  Your code might not, but you sure do!  Spending all that time writing
  require statements = :(

 If you are too lazy to write require statements then you are probably too
 lazy to write readable, well structured and efficient code. Besides, I
 don't
 use require statements, I use
$dbobject = singleton::getInstance('classname');

 I don't use autoload because *I* want to be in control. I prefer not to
 rely
 on automatuic features which may not work as expected.

 --
 Tony Marston
 http://www.tonymarston.net
 http://www.radicore.org

  On Thu, May 28, 2009 at 9:49 AM, Tony Marston
  t...@marston-home.demon.co.uk
  wrote:
 
 
  oorza...@gmail.com wrote in message
  news:000e0cd6ad1a9f7d3d046af89...@google.com...
   Two things:
  
   1. Try using the fully qualified path (ie /var/www/foo/bar.php instead
   of
   foo/bar.php)
   2. Look at setting up autoloading so you don't need to manually
 include
   anyway. If you're going OOP, autoloading is a must!
 
  I totally disagree. I have been doing OOP with PHP for years, and I have
  never used autoloading. It is just a feature that can be used, misused
 or
  abused just like any other. I choose not to use it, and my code does not
  suffer in the least!
 
  --
  Tony Marston
  http://www.tonymarston.net
  http://www.radicore.org
 
 
 
 
  --
  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: Re: [PHP] Re: PHP, OOP and AJAX

2009-05-28 Thread Tony Marston

Eddie Drapkin oorza...@gmail.com wrote in message 
news:68de37340905280801m6964d355l2d6d8ef773f3b...@mail.gmail.com...
 There's a huge difference between laziness and opting in to use an
 incredibly useful (and easy to properly deploy) feature to save myself 
 time
 so that I can spend more time writing that structured and efficient code 
 of
 which you speak.  And the problem with what you're saying is that you 
 still
 have to include 'singleton.php' somewhere in order to call its static
 methods,

I have a single general purpose include file which autmatically includes all 
other standard files, so I never have to explicity load my singleton class.

 and I'd rather just spend 30 minutes writing an autoloader object
 and letting it deal with finding any of the classes I use then trying to
 keep track of legacy code I didn't write and require'ing them all over the
 place.

I'd rather not waste 30 minutes of my time writing a feature that I don't 
need.

The difference between using and not using the autoload feature does not 
have any measurable impact on either my development times, nor the execution 
of my code, so I choose to not use it. That's my choice, and I'm sticking to 
it.

 The way I look at it, if you spend all your time handling things that you
 could automate - and if written properly, will always work as expected 
 (it's
 called unit testing and debugging) - then you have no time to write that
 structured and efficient code in order to meet your deadlines! :)

Not using autoload does not have any noticeable effect on my deadlines, so I 
have no incentive to use it. Just because you say that I *should* use it 
carries no weight at all.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

 On Thu, May 28, 2009 at 10:53 AM, Tony Marston 
 t...@marston-home.demon.co.uk wrote:

 Eddie Drapkin oorza...@gmail.com wrote in message
 news:68de37340905280737t3e1ad844y188ab8fa08f17...@mail.gmail.com...
  Your code might not, but you sure do!  Spending all that time writing
  require statements = :(

 If you are too lazy to write require statements then you are probably 
 too
 lazy to write readable, well structured and efficient code. Besides, I
 don't
 use require statements, I use
$dbobject = singleton::getInstance('classname');

 I don't use autoload because *I* want to be in control. I prefer not to
 rely
 on automatuic features which may not work as expected.

 --
 Tony Marston
 http://www.tonymarston.net
 http://www.radicore.org

  On Thu, May 28, 2009 at 9:49 AM, Tony Marston
  t...@marston-home.demon.co.uk
  wrote:
 
 
  oorza...@gmail.com wrote in message
  news:000e0cd6ad1a9f7d3d046af89...@google.com...
   Two things:
  
   1. Try using the fully qualified path (ie /var/www/foo/bar.php 
   instead
   of
   foo/bar.php)
   2. Look at setting up autoloading so you don't need to manually
 include
   anyway. If you're going OOP, autoloading is a must!
 
  I totally disagree. I have been doing OOP with PHP for years, and I 
  have
  never used autoloading. It is just a feature that can be used, misused
 or
  abused just like any other. I choose not to use it, and my code does 
  not
  suffer in the least!
 
  --
  Tony Marston
  http://www.tonymarston.net
  http://www.radicore.org
 
 
 
 
  --
  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


 



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



Re: [PHP] PHP, OOP and AJAX

2009-05-28 Thread Tom Worster
On 5/28/09 7:31 AM, Julian Muscat Doublesin opensourc...@gmail.com
wrote:

 I had been programming in ASP.NET for years using Object Oriented
 Princeliness but decided to walk away from that.  I am now researching and
 specialising in the open source world.

yay!


 I have started to develop a project using MySQL, PHP and OOP.

oh. not walking away from oop after all? sad ;-)


 So far I have
 succeed. However I got stuck once I started implement AJAX using the AJAX
 tutorial from w3schools.com.

if using ajax, i recommend you take a look at jquery. i'm really quite taken
with it. it makes browser-independent ajax much easier.


 What I have discovered is: for some reason when you call a file that
 requires other fies using the REQUIRE or INCLUDE it just does not work. I
 can conform this as I have tested with out the the functions.

i can't imagine a reason why an include would fail because the script was
invoked via XHR. my ajax back-end php scripts use included files. are you
sure this isn't a problem with the include path? to debug you could try
writing ini_get('include_path') to your log file.




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



Re: [PHP] Re: PHP, OOP and AJAX

2009-05-28 Thread Ashley Sheridan
On Thu, 2009-05-28 at 16:17 +0300, Olexandr Heneralov wrote:
 Hi!
 Do not use low-level AJAX.
 There are many frameworks for ajax (JQUERY).
 Try to use PHP frameworks like symfony, zend framework. They simplify your
 work.
 
 
 2009/5/28 Lenin le...@phpxperts.net
 
  2009/5/28 kranthi kranthi...@gmail.com
 
  
  
   i recommend you firebug firefox adddon (just go to the net tab and you
   can see all the details of the communication between client and
   server)
   and i find it helpful to use a standard javascript(jQuery in my case)
   library instead of highly limited plain javascript  language
  
  I also recommend using FirePHP with FireBug here's a nicely written
  tutorial
  on how to use them both together for Ajax'ed pages. http://tr.im/iyvl
  Thanks
  Lenin
  www.twitter.com/nine_L
 
Real coders use low-level ajax... and code with rocks too ;)


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] PHP OOP

2009-02-12 Thread Kyle Terry
On Mon, Feb 9, 2009 at 11:12 AM, Yannick Mortier
mvmort...@googlemail.comwrote:

 2009/2/9 tedd t...@sperling.com:
 snip


 Yes C++ is not bad for this, but it has also got some flaws.


What language doesn't have flaws, dude? Out of all the OOP C++ and java are
probably the most solid. And I _hate_ java...



 
  However, while I don't know PHP OOP, I am open to considering it because
 of
  the proliferation of web based applications. My personal opinion is
 that's
  where all programming is headed anyway, but that's just my opinion.
 
  With that said, what's the differences and advantages/disadvantages
 between
  C++ and PHP OOP?
 
  Cheers,
 
  tedd
 

 Both of them have got the disadvantage that they also support
 procedural programming. Some of your students will for sure not
 understand OOP immediately and they'll avoid using it this way.

 I guess Java is really a good idea, there are some great Editors
 around for it (Netbeans...) It's completely OOP and there are many
 great tutorials for it in the net, so a willing student can easily go
 on after the class is over.

 I really didn't like Java some months ago, but I have to learn it at
 school myself now and I think it's great to learn. It avoids most of
 the errors that come from C++'s pointers etc. so you can really focus
 on teaching OOP and not why you must always reserve memory etc.

 Later on it'll sure be easy to switch to other languages (though I
 can't really tell this because I started with C++ when I was ten years
 old and discovered PHP later and get to know Java know)

 So: My vote goes to Java, or if you want a decision between C++ and
 PHP it's C++.


 --
 Currently developing a browsergame...
 http://www.p-game.de
 Trade - Expand - Fight

 Follow me at twitter!
 http://twitter.com/moortier

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




-- 
Kyle Terry | www.kyleterry.com
Help kick start VOOM (Very Open Object Model) for a library of PHP classes.
http://www.voom.me | IRC EFNet #voom


Re: [PHP] PHP OOP

2009-02-12 Thread Virgilio Quilario
Java is really awesome at OOP and it is great for teaching OOP or,
shall we say illustrating OOP.
OOP is a programming technique in general without any bias towards any
programming language.
Good background on OOP concepts is essential in learning language
specific OOP implementation.
So don't worry about languages.
The important thing is, you know what OOP means.

Also you can't compare PHP to other programming languages.
PHP is new and mainly built for the web.
With its raw power, it is simply incomparable.

virgil
http://www.jampmark.com

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



[PHP] Re: PHP OOP

2009-02-10 Thread Ondrej Kulaty
I don't think that PHP is good language for teaching OOP as many folks above 
said. I have never programmed in OOP style but i plan to learn it. I started 
in PHP but i was little confused and i am used to program in procedural way 
in PHP, so i've decided to learn some pure OOP language. I am reading a book 
OOP Demystified, there are examples in both C++ and Java. And imo Java code 
is much more readable and understandable. So i think that Java is the best 
for learning OOP. I am also considering learning C#, if you dont mind that 
it's closely related to windows, it might be also a good choice.
-- 

tedd t...@sperling.com píse v diskusním príspevku 
news:p0624080dc5b5fff1c...@[192.168.1.101]...
 Hi gang:

 At the college where I teach, they are considering teaching OOP, but they 
 don't want to settle on a specific language.

 My thoughts are it's difficult to teach OOP without a language -- 
 while the general concepts of OOP are interesting, people need to see how 
 concepts are applied to understand how they work -- thus I think a 
 specific language is required

 I lean toward C++ because I wrote in it for a few years AND C++ appears to 
 be the most common, widespread, and popular OOP language.

 However, while I don't know PHP OOP, I am open to considering it because 
 of the proliferation of web based applications. My personal opinion is 
 that's where all programming is headed anyway, but that's just my opinion.

 With that said, what's the differences and advantages/disadvantages 
 between C++ and PHP OOP?

 Cheers,

 tedd


 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com 



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



Re: [PHP] PHP OOP

2009-02-10 Thread Marcus Gnaß

Paul M Foster wrote:

On Mon, Feb 09, 2009 at 11:02:37AM -0500, tedd wrote:
  
As a side note, I think students should learn a language like C before

learning something like Perl, Python or PHP. Having to deal with
defining/declaring variables and their storage methods before use I
think makes for more conscientious programmers. And pointers are an
education all on their own. ;-}
  
For teaching programming or OOP I would choose a language which 
concentrates on the topic. The hard stuff, which you have to deal with 
in C for example, can be learned later. I'm glad that I started 
programming in Pascal, not in C. If today I had to learn programming as 
such I would definitively opt for Python! My choice for learning OOP 
would be Python or even better Java cause you don't have the choice to 
do it in a procedural way.


Marcus

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



Re: [PHP] PHP OOP

2009-02-10 Thread Carlos Medina

Marcus Gnaß schrieb:

Paul M Foster wrote:

On Mon, Feb 09, 2009 at 11:02:37AM -0500, tedd wrote:
  As a side note, I think students should learn a language like C before
learning something like Perl, Python or PHP. Having to deal with
defining/declaring variables and their storage methods before use I
think makes for more conscientious programmers. And pointers are an
education all on their own. ;-}
  
For teaching programming or OOP I would choose a language which 
concentrates on the topic. The hard stuff, which you have to deal with 
in C for example, can be learned later. I'm glad that I started 
programming in Pascal, not in C. If today I had to learn programming as 
such I would definitively opt for Python! My choice for learning OOP 
would be Python or even better Java cause you don't have the choice to 
do it in a procedural way.


Marcus

Hi @ all,
but this is a php list...

Regards

Carlos

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



Re: [PHP] PHP OOP

2009-02-10 Thread Byron
Where I study, Intro to OOP is taught in C# using Visual Studio 2003 and
further OOP concepts are taught in Java, with the academic computer science
of OOP alongside.

On Wed, Feb 11, 2009 at 2:40 AM, Carlos Medina i...@simply-networks.dewrote:

 Marcus Gnaß schrieb:

 Paul M Foster wrote:

 On Mon, Feb 09, 2009 at 11:02:37AM -0500, tedd wrote:
  As a side note, I think students should learn a language like C before
 learning something like Perl, Python or PHP. Having to deal with
 defining/declaring variables and their storage methods before use I
 think makes for more conscientious programmers. And pointers are an
 education all on their own. ;-}


 For teaching programming or OOP I would choose a language which
 concentrates on the topic. The hard stuff, which you have to deal with in C
 for example, can be learned later. I'm glad that I started programming in
 Pascal, not in C. If today I had to learn programming as such I would
 definitively opt for Python! My choice for learning OOP would be Python or
 even better Java cause you don't have the choice to do it in a procedural
 way.

 Marcus

 Hi @ all,
 but this is a php list...

 Regards

 Carlos


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




-- 
I'm going out to find myself, if you see me here, keep me here untill I can
catch up

If I haven't said so already,

Thanks
Byron


Re: [PHP] PHP OOP

2009-02-10 Thread Andrew Ballard
On Tue, Feb 10, 2009 at 8:40 AM, Carlos Medina i...@simply-networks.de wrote:
 Marcus Gnaß schrieb:

 Paul M Foster wrote:

 On Mon, Feb 09, 2009 at 11:02:37AM -0500, tedd wrote:
  As a side note, I think students should learn a language like C before
 learning something like Perl, Python or PHP. Having to deal with
 defining/declaring variables and their storage methods before use I
 think makes for more conscientious programmers. And pointers are an
 education all on their own. ;-}


 For teaching programming or OOP I would choose a language which
 concentrates on the topic. The hard stuff, which you have to deal with in C
 for example, can be learned later. I'm glad that I started programming in
 Pascal, not in C. If today I had to learn programming as such I would
 definitively opt for Python! My choice for learning OOP would be Python or
 even better Java cause you don't have the choice to do it in a procedural
 way.

 Marcus

 Hi @ all,
 but this is a php list...

 Regards

 Carlos


Yes, it is, but the original question was about OOP and not
specifically about PHP. It seems fair enough to me for someone to ask
the question on this list since PHP was one of the languages being
considered, even if consensus among the list seems to be that PHP
would not be the best choice for teaching a course on OOP.

Andrew

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



Re: [PHP] PHP OOP

2009-02-10 Thread tedd

At 9:36 AM -0500 2/10/09, Andrew Ballard wrote:
On Tue, Feb 10, 2009 at 8:40 AM, Carlos Medina 
i...@simply-networks.de wrote:

  Marcus Gnaß schrieb:

  Hi @ all,

 but this is a php list...

 Regards

 Carlos



Yes, it is, but the original question was about OOP and not
specifically about PHP. It seems fair enough to me for someone to ask
the question on this list since PHP was one of the languages being
considered, even if consensus among the list seems to be that PHP
would not be the best choice for teaching a course on OOP.

Andrew



Andrew:

Absolutely, you're not out of line at all.

TI have found in my life that there will always 
be those who have a better idea, if you know what 
I mean.


The point of the post (me being the OP) was to 
sample other people's opinion as to what would be 
best language to use to teach OOP, and that 
included considering php, thus the relevancy.


The answer turns out to be Java (1) or C++ (2) 
depending upon the environment and availability 
of resources.


Why people have to get on and comment that this 
is a php list is beyond me, duh.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] PHP OOP

2009-02-10 Thread German Geek
A loosely typed language like PHP might not be the best choice for teaching
OOP, because even though PHP makes it easier with loose types, you should
know about them and how they are stored etc.

PHP is a great language but maybe not strict enough for students to
understand all the errors that can occur. I would recommend encouraging
learning PHP though as it has become both an important and fast and easy
language to program in. For that it's also amazingly fast in execution.

Cheers,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Garry Shandling  - I'm dating a woman now who, evidently, is unaware of
it.

2009/2/11 tedd tedd.sperl...@gmail.com

 At 9:36 AM -0500 2/10/09, Andrew Ballard wrote:

 On Tue, Feb 10, 2009 at 8:40 AM, Carlos Medina i...@simply-networks.de
 wrote:
   Marcus Gnaß schrieb:

   Hi @ all,

  but this is a php list...

  Regards

  Carlos


 Yes, it is, but the original question was about OOP and not
 specifically about PHP. It seems fair enough to me for someone to ask
 the question on this list since PHP was one of the languages being
 considered, even if consensus among the list seems to be that PHP
 would not be the best choice for teaching a course on OOP.

 Andrew



 Andrew:

 Absolutely, you're not out of line at all.

 TI have found in my life that there will always be those who have a better
 idea, if you know what I mean.

 The point of the post (me being the OP) was to sample other people's
 opinion as to what would be best language to use to teach OOP, and that
 included considering php, thus the relevancy.

 The answer turns out to be Java (1) or C++ (2) depending upon the
 environment and availability of resources.

 Why people have to get on and comment that this is a php list is beyond me,
 duh.

 Cheers,

 tedd
 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

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




[PHP] PHP OOP

2009-02-09 Thread tedd

Hi gang:

At the college where I teach, they are considering teaching OOP, but 
they don't want to settle on a specific language.


My thoughts are it's difficult to teach OOP without a language -- 
while the general concepts of OOP are interesting, people need to see 
how concepts are applied to understand how they work -- thus I think 
a specific language is required


I lean toward C++ because I wrote in it for a few years AND C++ 
appears to be the most common, widespread, and popular OOP language.


However, while I don't know PHP OOP, I am open to considering it 
because of the proliferation of web based applications. My personal 
opinion is that's where all programming is headed anyway, but that's 
just my opinion.


With that said, what's the differences and advantages/disadvantages 
between C++ and PHP OOP?


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] PHP OOP

2009-02-09 Thread Kyle Terry
On Mon, Feb 9, 2009 at 8:02 AM, tedd t...@sperling.com wrote:
 Hi gang:

 At the college where I teach, they are considering teaching OOP, but they
 don't want to settle on a specific language.

 My thoughts are it's difficult to teach OOP without a language -- while the
 general concepts of OOP are interesting, people need to see how concepts are
 applied to understand how they work -- thus I think a specific language is
 required

 I lean toward C++ because I wrote in it for a few years AND C++ appears to
 be the most common, widespread, and popular OOP language.

 However, while I don't know PHP OOP, I am open to considering it because of
 the proliferation of web based applications. My personal opinion is that's
 where all programming is headed anyway, but that's just my opinion.

 With that said, what's the differences and advantages/disadvantages between
 C++ and PHP OOP?

 Cheers,

 tedd


 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

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



In my personal opinion, C++ would probably be the best language to
teach OOP concepts in. That or Python.

-- 
Kyle Terry | www.kyleterry.com
Help kick start VOOM (Very Open Object Model) for a library of PHP classes.
http://www.voom.me | IRC EFNet #voom

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



Re: [PHP] PHP OOP

2009-02-09 Thread Thodoris



Hi gang:

At the college where I teach, they are considering teaching OOP, but 
they don't want to settle on a specific language.


My thoughts are it's difficult to teach OOP without a language -- 
while the general concepts of OOP are interesting, people need to see 
how concepts are applied to understand how they work -- thus I think a 
specific language is required


I lean toward C++ because I wrote in it for a few years AND C++ 
appears to be the most common, widespread, and popular OOP language.


However, while I don't know PHP OOP, I am open to considering it 
because of the proliferation of web based applications. My personal 
opinion is that's where all programming is headed anyway, but that's 
just my opinion.


With that said, what's the differences and advantages/disadvantages 
between C++ and PHP OOP?


Cheers,

tedd



IMHO I think that you are right about using a specific language and you 
should strongly insist on that. Someone needs to see how objects are 
taking flesh and bones in real life and not just theoretically.


You could consider Java as well before taking your final decision.

--
Thodoris


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



Re: [PHP] PHP OOP

2009-02-09 Thread Eric Butera
On Mon, Feb 9, 2009 at 11:20 AM, Thodoris t...@kinetix.gr wrote:

 Hi gang:

 At the college where I teach, they are considering teaching OOP, but they
 don't want to settle on a specific language.

 My thoughts are it's difficult to teach OOP without a language -- while
 the general concepts of OOP are interesting, people need to see how concepts
 are applied to understand how they work -- thus I think a specific language
 is required

 I lean toward C++ because I wrote in it for a few years AND C++ appears to
 be the most common, widespread, and popular OOP language.

 However, while I don't know PHP OOP, I am open to considering it because
 of the proliferation of web based applications. My personal opinion is
 that's where all programming is headed anyway, but that's just my opinion.

 With that said, what's the differences and advantages/disadvantages
 between C++ and PHP OOP?

 Cheers,

 tedd


 IMHO I think that you are right about using a specific language and you
 should strongly insist on that. Someone needs to see how objects are taking
 flesh and bones in real life and not just theoretically.

 You could consider Java as well before taking your final decision.

 --
 Thodoris


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



Especially since PHP is trying to be Java. :)

-- 
http://www.voom.me | EFnet: #voom

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



Re: [PHP] PHP OOP

2009-02-09 Thread Nathan Rixham

Eric Butera wrote:

On Mon, Feb 9, 2009 at 11:20 AM, Thodoris t...@kinetix.gr wrote:

Hi gang:

At the college where I teach, they are considering teaching OOP, but they
don't want to settle on a specific language.

My thoughts are it's difficult to teach OOP without a language -- while
the general concepts of OOP are interesting, people need to see how concepts
are applied to understand how they work -- thus I think a specific language
is required

I lean toward C++ because I wrote in it for a few years AND C++ appears to
be the most common, widespread, and popular OOP language.

However, while I don't know PHP OOP, I am open to considering it because
of the proliferation of web based applications. My personal opinion is
that's where all programming is headed anyway, but that's just my opinion.

With that said, what's the differences and advantages/disadvantages
between C++ and PHP OOP?

Cheers,

tedd


IMHO I think that you are right about using a specific language and you
should strongly insist on that. Someone needs to see how objects are taking
flesh and bones in real life and not just theoretically.

You could consider Java as well before taking your final decision.

--
Thodoris


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




Especially since PHP is trying to be Java. :)



take a wild guess as to what I'm going to day.. java is v good language 
to learn OO specific principals and I'd strongly recommend it - while I 
may get more done with php oo practically, I learn and undertand a lot 
more with java.


regards!

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



Re: [PHP] PHP OOP

2009-02-09 Thread Per Jessen
tedd wrote:

 I lean toward C++ because I wrote in it for a few years AND C++
 appears to be the most common, widespread, and popular OOP language.

I would agree, although I suspect Java is also a good candidate.

 However, while I don't know PHP OOP, I am open to considering it
 because of the proliferation of web based applications. 

Don't - compile-time type checking is essential to OOP.

 My personal opinion is that's where all programming is headed anyway,
 but that's just my opinion.

Which you're certainly entitled to - I just can't quite see the Linux
kernel or bind or an audio driver written as a web-app :-)


/Per

-- 
Per Jessen, Zürich (1.6°C)


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



Re: [PHP] PHP OOP

2009-02-09 Thread Per Jessen
tedd wrote:

 I lean toward C++ because I wrote in it for a few years AND C++
 appears to be the most common, widespread, and popular OOP language.

I would agree, although I suspect Java is also a good candidate.

 However, while I don't know PHP OOP, I am open to considering it
 because of the proliferation of web based applications. 

Don't - compile-time type checking is essential to OOP.

 My personal opinion is that's where all programming is headed anyway,
 but that's just my opinion.

Which you're certainly entitled to - I just can't quite see the Linux
kernel or bind or an audio driver written as a web-app or in php :-)


/Per

-- 
Per Jessen, Zürich (1.6°C)


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



Re: [PHP] PHP OOP

2009-02-09 Thread Stuart
2009/2/9 tedd t...@sperling.com:
 Hi gang:

 At the college where I teach, they are considering teaching OOP, but they
 don't want to settle on a specific language.

 My thoughts are it's difficult to teach OOP without a language -- while the
 general concepts of OOP are interesting, people need to see how concepts are
 applied to understand how they work -- thus I think a specific language is
 required

 I lean toward C++ because I wrote in it for a few years AND C++ appears to
 be the most common, widespread, and popular OOP language.

 However, while I don't know PHP OOP, I am open to considering it because of
 the proliferation of web based applications. My personal opinion is that's
 where all programming is headed anyway, but that's just my opinion.

 With that said, what's the differences and advantages/disadvantages between
 C++ and PHP OOP?

C++ is a good option, but if OOP is the focus it might be better to
use Java or similar where you don't need to worry so much about memory
management. If you're dealing with people who know C then C++ will
work well, otherwise not. The worst thing you can do is skip over the
details of C++ development because you want to focus on OOP. You'll
end up with a bunch of people who *think* they can code in C++ but
really haven't got a clue.

Personally I'd have preferred my university to use Smalltalk, but none
of the professors knew it so I had to teach myself. It's the original
and IMHO still the best implementation of OOP concepts around.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] PHP OOP

2009-02-09 Thread Paul M Foster
On Mon, Feb 09, 2009 at 11:02:37AM -0500, tedd wrote:

 Hi gang:

 At the college where I teach, they are considering teaching OOP, but
 they don't want to settle on a specific language.

 My thoughts are it's difficult to teach OOP without a language --
 while the general concepts of OOP are interesting, people need to see
 how concepts are applied to understand how they work -- thus I think
 a specific language is required

 I lean toward C++ because I wrote in it for a few years AND C++
 appears to be the most common, widespread, and popular OOP language.

 However, while I don't know PHP OOP, I am open to considering it
 because of the proliferation of web based applications. My personal
 opinion is that's where all programming is headed anyway, but that's
 just my opinion.

 With that said, what's the differences and advantages/disadvantages
 between C++ and PHP OOP?

I don't know Java, but I suspect it's a more purely OO language than
C++. I *have* coded in C++, and the OO aspects of C++ are like a bolt-on
on the C language. There are some odd aspects of C++ because of its
history as originally a preprocessor hack on top of C.

PHP is *not* a good example for OO. There are a lot of OO principles it
doesn't follow.

I would have suggested Smalltalk, the original OO language, except that
no one uses it any more, and other languages don't necessarily fully
implement OO as done in Smalltalk. You're right about using a language
which implements OO in a realistic way for today's programmers.

I also agree you need a language in which to teach OO. Otherwise, this
is all just theory, and won't stick with the students. Imagine learning
algebra but never solving equations in the class. You'd forget the whole
thing ten minutes after the class was over.

In fact, it seems a little backward to teach OO programming as a lone
subject. I would instead opt for teaching a language first, and OO as a
secondary part of that course. Learning C++ will go a long way in
assisting the student to learn Java, or vice versa. My experience
programming C has been invaluable in coding under PHP.

As a side note, I think students should learn a language like C before
learning something like Perl, Python or PHP. Having to deal with
defining/declaring variables and their storage methods before use I
think makes for more conscientious programmers. And pointers are an
education all on their own. ;-}

Paul

-- 
Paul M. Foster

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



Re: [PHP] PHP OOP

2009-02-09 Thread Eric Butera
On Mon, Feb 9, 2009 at 12:19 PM, Stuart stut...@gmail.com wrote:
 2009/2/9 tedd t...@sperling.com:
 Hi gang:

 At the college where I teach, they are considering teaching OOP, but they
 don't want to settle on a specific language.

 My thoughts are it's difficult to teach OOP without a language -- while the
 general concepts of OOP are interesting, people need to see how concepts are
 applied to understand how they work -- thus I think a specific language is
 required

 I lean toward C++ because I wrote in it for a few years AND C++ appears to
 be the most common, widespread, and popular OOP language.

 However, while I don't know PHP OOP, I am open to considering it because of
 the proliferation of web based applications. My personal opinion is that's
 where all programming is headed anyway, but that's just my opinion.

 With that said, what's the differences and advantages/disadvantages between
 C++ and PHP OOP?

 C++ is a good option, but if OOP is the focus it might be better to
 use Java or similar where you don't need to worry so much about memory
 management. If you're dealing with people who know C then C++ will
 work well, otherwise not. The worst thing you can do is skip over the
 details of C++ development because you want to focus on OOP. You'll
 end up with a bunch of people who *think* they can code in C++ but
 really haven't got a clue.

 Personally I'd have preferred my university to use Smalltalk, but none
 of the professors knew it so I had to teach myself. It's the original
 and IMHO still the best implementation of OOP concepts around.

 -Stuart

 --
 http://stut.net/

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



Actually I made up the term object-oriented, and I can tell you I
did not have C++ in mind.
http://video.google.com/videoplay?docid=-2950949730059754521
http://en.wikiquote.org/wiki/Alan_Kay


-- 
http://www.voom.me | EFnet: #voom

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



Re: [PHP] PHP OOP

2009-02-09 Thread Per Jessen
Paul M Foster wrote:

 PHP is *not* a good example for OO. There are a lot of OO principles
 it doesn't follow.
 
 I would have suggested Smalltalk, the original OO language, except
 that no one uses it any more, and other languages don't necessarily
 fully implement OO as done in Smalltalk. You're right about using a 
 language which implements OO in a realistic way for today's
 programmers.

Depends exactly what Tedds class is meant to be - whether it's about
programming or computer science.  For the latter, Eiffel is also a good
OO language.


/Per

-- 
Per Jessen, Zürich (1.9°C)


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



Re: [PHP] PHP OOP

2009-02-09 Thread Yannick Mortier
2009/2/9 tedd t...@sperling.com:
 Hi gang:

 At the college where I teach, they are considering teaching OOP, but they
 don't want to settle on a specific language.


I guess that is not a good idea, you should really combine it with a
language, as some students will be curious enough to play around with
it at home and so they'll also learn more.

 My thoughts are it's difficult to teach OOP without a language -- while the
 general concepts of OOP are interesting, people need to see how concepts are
 applied to understand how they work -- thus I think a specific language is
 required

 I lean toward C++ because I wrote in it for a few years AND C++ appears to
 be the most common, widespread, and popular OOP language.


Yes C++ is not bad for this, but it has also got some flaws.


 However, while I don't know PHP OOP, I am open to considering it because of
 the proliferation of web based applications. My personal opinion is that's
 where all programming is headed anyway, but that's just my opinion.

 With that said, what's the differences and advantages/disadvantages between
 C++ and PHP OOP?

 Cheers,

 tedd


Both of them have got the disadvantage that they also support
procedural programming. Some of your students will for sure not
understand OOP immediately and they'll avoid using it this way.

I guess Java is really a good idea, there are some great Editors
around for it (Netbeans...) It's completely OOP and there are many
great tutorials for it in the net, so a willing student can easily go
on after the class is over.

I really didn't like Java some months ago, but I have to learn it at
school myself now and I think it's great to learn. It avoids most of
the errors that come from C++'s pointers etc. so you can really focus
on teaching OOP and not why you must always reserve memory etc.

Later on it'll sure be easy to switch to other languages (though I
can't really tell this because I started with C++ when I was ten years
old and discovered PHP later and get to know Java know)

So: My vote goes to Java, or if you want a decision between C++ and
PHP it's C++.


-- 
Currently developing a browsergame...
http://www.p-game.de
Trade - Expand - Fight

Follow me at twitter!
http://twitter.com/moortier

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



Re: [PHP] PHP OOP

2009-02-09 Thread Larry Garfield
On Monday 09 February 2009 10:02:37 am tedd wrote:
 Hi gang:

 At the college where I teach, they are considering teaching OOP, but
 they don't want to settle on a specific language.

 My thoughts are it's difficult to teach OOP without a language --
 while the general concepts of OOP are interesting, people need to see
 how concepts are applied to understand how they work -- thus I think
 a specific language is required

 I lean toward C++ because I wrote in it for a few years AND C++
 appears to be the most common, widespread, and popular OOP language.

 However, while I don't know PHP OOP, I am open to considering it
 because of the proliferation of web based applications. My personal
 opinion is that's where all programming is headed anyway, but that's
 just my opinion.

 With that said, what's the differences and advantages/disadvantages
 between C++ and PHP OOP?

 Cheers,

 tedd

I definitely agree that teaching OOP without a language to write it in is a 
very stupid idea.  However, part of the problem is that there is in practice 
no one version of OOP.

Java is probably the best example of academically pure classic OOP (that is, 
class-based).  That can be good for teaching, but it can also suck for 
developing because you have to do things in an academically formal way.

Javascript, on the other hand, is a prototype-based language.  Technically 
that's also OOP, or can be, but the code is entirely different conceptually 
when functions, methods, objects, and classes are all the same thing. :-)

PHP's OOP is very closely modeled on Java's, but with some interesting 
additions.  PHP 5.3 adds a few more and 5.4/6.0 is likely to add traits, which 
are another animal entirely.  PHP is also a hybrid language and, by nature of 
being a shared-nothing scripting language OOP is often the wrong choice 
because of the setup and initialization costs.

C++ has a little of each, albeit in a frequently convoluted way.  It also 
has about 30 more types of access control than any other language I know, for 
better or worse.

LISP is its own creature, closer to Javascript than to anything else I just 
mentioned.  (Or arguably Javascript is closer to LISP.)

Personally, I recommend teaching programming first in C++.  Force them to do 
the hard stuff so they appreciate what the runtime is doing for them in higher 
level languages.  It also means you can teach procedural and OOP in the same 
syntax.  Then once they've gotten a few bruises in C++, expose them to Java, 
Javascript, PHP, etc. to let them see what higher level work actually gets 
done in these days.

-- 
Larry Garfield
la...@garfieldtech.com

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



[PHP] OOP - Calling methods from classes that are inheriting?

2008-09-21 Thread Ben Stones
Hi,

How do I call methods from classes that are inherited? I want to add a
mysql_num_rows() function to a second class that is an addon to a MySQL
query in the first class. The first class will be used in several different
classes for different parts of the site so I don't want to directly add the
num_rows to the first class method as the query won't just be used for this
function.

Hope I have made myself as clear as possible!

Cheers!


[PHP] OOP in PHP

2007-08-15 Thread Patrik Hasibuan
Dear my friends,

This is the first time for me to use OOP concept of PHP. I wrote still a very 
simple codes but it doesn't work as my manual book taught. the book titled 
MySQL/PHP Database Application by Jay Greenspan say these lines should work 
but in fact it don't work as expected.
Here is my code:
===
//pelangganbaru.php
?php
require koneksi.php;
$sqlnya=select country from countries;
$klas=new koneksi($sqlnya);
?
===
//koneksi.php
!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

HTML
HEAD
  META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 
2006), see www.w3.org

/HEAD

BODY
?php
class koneksi{
$namakompie=127.0.0.1;
$un=root;
$pw=mysqlpw;
$sqlnya;
$kueri;

function koneksi($sqlnya){
echo superclass koneksi dipanggilbr;
$konek=mysql_connect($namakompie,$un,$pw);
if ($konek){
echo koneksi berhasil (connection succeeded)br;
$mybd=mysql_select_db(survey,$konek);
$kueri=mysql_query($sqlnya,$konek);
}else{
echo I can't talk to the serverbr;
exit();
}
return $kueri;
}

}
?
/BODY
/HTML
=

Theoritically if Class koneksi is being initialized than it prints koneksi 
berhasil (connection succeeded) but it doesn't.

Please tell me what is my mistake.

Thank you very much in advance.
-- 
Patrik Hasibuan [EMAIL PROTECTED]
Junior Programmer

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



Re: [PHP] OOP in PHP

2007-08-15 Thread Nathan Nobbe
what sort of error are you encountering ?

-nathan

On 8/15/07, Patrik Hasibuan [EMAIL PROTECTED] wrote:

 Dear my friends,

 This is the first time for me to use OOP concept of PHP. I wrote still a
 very simple codes but it doesn't work as my manual book taught. the book
 titled MySQL/PHP Database Application by Jay Greenspan say these lines
 should work but in fact it don't work as expected.
 Here is my code:
 ===
 //pelangganbaru.php
 ?php
 require koneksi.php;
 $sqlnya=select country from countries;
 $klas=new koneksi($sqlnya);
 ?
 ===
 //koneksi.php
 !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

 HTML
 HEAD
   META name=generator content=HTML Tidy for Linux/x86 (vers 31 October
 2006), see www.w3.org

 /HEAD

 BODY
 ?php
 class koneksi{
 $namakompie=127.0.0.1;
 $un=root;
 $pw=mysqlpw;
 $sqlnya;
 $kueri;

 function koneksi($sqlnya){
 echo superclass koneksi dipanggilbr;
 $konek=mysql_connect($namakompie,$un,$pw);
 if ($konek){
 echo koneksi berhasil (connection succeeded)br;
 $mybd=mysql_select_db(survey,$konek);
 $kueri=mysql_query($sqlnya,$konek);
 }else{
 echo I can't talk to the serverbr;
 exit();
 }
 return $kueri;
 }

 }
 ?
 /BODY
 /HTML
 =

 Theoritically if Class koneksi is being initialized than it prints
 koneksi berhasil (connection succeeded) but it doesn't.

 Please tell me what is my mistake.

 Thank you very much in advance.
 --
 Patrik Hasibuan [EMAIL PROTECTED]
 Junior Programmer

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




Re: [PHP] OOP in PHP

2007-08-15 Thread Robert . Degen

 Theoritically if Class koneksi is being initialized than it 
 prints koneksi berhasil (connection succeeded) but it doesn't.

What does it? Just nothing? No warnings at all? Possibly disabled?

so far

rob

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



Re: [PHP] OOP in PHP

2007-08-15 Thread Jim Lucas


A few missing pieces in your code.  Take a look below within your class.  I 
corrected it.

try also using include_once instead of require

and make sure that your error level and reporting are turned on so you can see 
what is happening.


Patrik Hasibuan wrote:

Dear my friends,

This is the first time for me to use OOP concept of PHP. I wrote still a very simple 
codes but it doesn't work as my manual book taught. the book titled MySQL/PHP 
Database Application by Jay Greenspan say these lines should work but in fact it 
don't work as expected.
Here is my code:
===
//pelangganbaru.php
?php
require koneksi.php;
$sqlnya=select country from countries;
$klas=new koneksi($sqlnya);
?
===
//koneksi.php
!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

HTML
HEAD
  META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see 
www.w3.org

/HEAD

BODY
?php
class koneksi{
$namakompie=127.0.0.1;

var $namakompie='127.0.0.1';

$un=root;

var $un='root';

$pw=mysqlpw;

var $pw='mysqlpw';

$sqlnya;

var $sqlnya;

$kueri;

var $kueri;


function koneksi($sqlnya){
echo superclass koneksi dipanggilbr;
$konek=mysql_connect($namakompie,$un,$pw);

$konek=mysql_connect($this-namakompie, $this-un, $this-pw);

if ($konek){
echo koneksi berhasil (connection succeeded)br;
$mybd=mysql_select_db(survey,$konek);
$kueri=mysql_query($sqlnya,$konek);
}else{
echo I can't talk to the serverbr;
exit();
}
return $kueri;
}

}
?
/BODY
/HTML
=

Theoritically if Class koneksi is being initialized than it prints koneksi 
berhasil (connection succeeded) but it doesn't.

Please tell me what is my mistake.

Thank you very much in advance.



--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] OOP in PHP

2007-08-15 Thread Patrik Hasibuan
Dear Jim,

You've solved my problem, Jim. Thank you very much.

Now, my code give the output as my expectation:

superclass koneksi dipanggil
koneksi berhasil
negara-
. 
But come another problem, namely: the $negara is empty. I tried to read the 
documentation on 

http://www.php.net/manual/en/language.types.object.php#language.types.object.casting

but I didn't manage to find the answer.

I suspect the return $kueri could be only for 'returning' a variable of 
boolean or string or number but not 'returning' an array (such as the result of 
mysql_query(select country from countries,$koneksi) ) or an object (such as 
the result of mysql_connect() ).

So how should I get the content of mysql_query() so I can get the value with 
mysql_fetch_row() or inherit array?
Is is also possible to re-use the result of mysql_connect() or inherit the 
$konek?

Here is my current code:

//pelangganbaru.php
?php
include_once koneksi.php;
$sqlnya=select country from countries;
$klas=new koneksi($sqlnya);
$brs=mysql_fetch_row($klas-kueri);
list($negara)=$brs;
echo option value=\$negara\$negara/option;

?
=
//koneksi.php
!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

HTML
HEAD
  META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 
2006), see www.w3.org

/HEAD

BODY
?php
class koneksi{
var $namakompie=127.0.0.1;
var $un=root;
var $pw=mysuccess;
var $sqlnya;
var $kueri;

function koneksi($sqlnya){
echo superclass koneksi dipanggilbr;
$konek=mysql_connect($this-namakompie,$this-un,$this-pw);
if ($konek){
echo koneksi berhasilbr;
$mybd=mysql_select_db(survey,$konek);
$kueri=mysql_query($sqlnya,$konek);
}else{
echo I can't talk to the serverbr;
exit();
}
return $kueri;
}

}
?
/BODY
/HTML

Please keep telling me.

Thank you very much in advance.
ps: Thanks a lot too to Nathan Nobe and Robert Gegen for their responds...

On Wed, 15 Aug 2007 09:00:56 -0700
Jim Lucas [EMAIL PROTECTED] wrote:

 
 A few missing pieces in your code.  Take a look below within your class.  I 
 corrected it.
 
 try also using include_once instead of require
 
 and make sure that your error level and reporting are turned on so you can 
 see what is happening.
 
 
 Patrik Hasibuan wrote:
  Dear my friends,
  
  This is the first time for me to use OOP concept of PHP. I wrote still a 
  very simple codes but it doesn't work as my manual book taught. the book 
  titled MySQL/PHP Database Application by Jay Greenspan say these lines 
  should work but in fact it don't work as expected.
  Here is my code:
  ===
  //pelangganbaru.php
  ?php
  require koneksi.php;
  $sqlnya=select country from countries;
  $klas=new koneksi($sqlnya);
  ?
  ===
  //koneksi.php
  !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
  
  HTML
  HEAD
META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 
  2006), see www.w3.org
  
  /HEAD
  
  BODY
  ?php
  class koneksi{
  $namakompie=127.0.0.1;
 var $namakompie='127.0.0.1';
  $un=root;
 var $un='root';
  $pw=mysqlpw;
 var $pw='mysqlpw';
  $sqlnya;
 var $sqlnya;
  $kueri;
 var $kueri;
  
  function koneksi($sqlnya){
  echo superclass koneksi dipanggilbr;
  $konek=mysql_connect($namakompie,$un,$pw);
 $konek=mysql_connect($this-namakompie, $this-un, $this-pw);
  if ($konek){
  echo koneksi berhasil (connection succeeded)br;
  $mybd=mysql_select_db(survey,$konek);
  $kueri=mysql_query($sqlnya,$konek);
  }else{
  echo I can't talk to the serverbr;
  exit();
  }
  return $kueri;
  }
  
  }
  ?
  /BODY
  /HTML
  =
  
  Theoritically if Class koneksi is being initialized than it prints 
  koneksi berhasil (connection succeeded) but it doesn't.
  
  Please tell me what is my mistake.
  
  Thank you very much in advance.
 
 
 -- 
 Jim Lucas
 
 Some men are born to greatness, some achieve greatness,
 and some have greatness thrust upon them.
 
 Twelfth Night, Act II, Scene V
  by William Shakespeare
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


-- 
Patrik Hasibuan [EMAIL PROTECTED]
Junior Programmer

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



Re: [PHP] OOP in PHP

2007-08-15 Thread Jim Lucas

Patrik Hasibuan wrote:

Dear Jim,

You've solved my problem, Jim. Thank you very much.

Now, my code give the output as my expectation:

superclass koneksi dipanggil
koneksi berhasil
negara-
. 
But come another problem, namely: the $negara is empty. I tried to read the documentation on 


http://www.php.net/manual/en/language.types.object.php#language.types.object.casting

but I didn't manage to find the answer.

I suspect the return $kueri could be only for 'returning' a variable of boolean or 
string or number but not 'returning' an array (such as the result of mysql_query(select 
country from countries,$koneksi) ) or an object (such as the result of mysql_connect() ).

So how should I get the content of mysql_query() so I can get the value with 
mysql_fetch_row() or inherit array?
Is is also possible to re-use the result of mysql_connect() or inherit the 
$konek?

Here is my current code:

//pelangganbaru.php
?php
include_once koneksi.php;
$sqlnya=select country from countries;
$klas=new koneksi($sqlnya);


Try this instead

if ( mysql_num_rows($klas)  0 ) {
while( list($negara) = mysql_fetch_row($klas) ) {
echo option value=\$negara\$negara/option;
}
} else {
echo 'No results found';
}

And within your class change your mysql_query line to this

$kueri=mysql_query($sqlnya,$konek) or die('MYSQL QUERY ERROR ['.mysql_errno($konek).'] 
'.mysql_error($konek));


This will make the system fail and kill the script if the query fails for some 
reason.
The die() part will then print the error number and what mysql thinks is wrong.

This isn't the best way to use error reporting in a production system, but since you are new at 
this, this is a simple way to do error reporting.


It is always a good idea to use is_resource($resource_handle_from_mysql) as a test to see if you did 
in fact get a valid resource id from the mysql_connect() call.




$brs=mysql_fetch_row($klas-kueri);
list($negara)=$brs;
echo option value=\$negara\$negara/option;

?
=
//koneksi.php
!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

HTML
HEAD
  META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see 
www.w3.org

/HEAD

BODY
?php
class koneksi{
var $namakompie=127.0.0.1;
var $un=root;
var $pw=mysuccess;
var $sqlnya;
var $kueri;

function koneksi($sqlnya){
echo superclass koneksi dipanggilbr;
$konek=mysql_connect($this-namakompie,$this-un,$this-pw);
if ($konek){
echo koneksi berhasilbr;
$mybd=mysql_select_db(survey,$konek);
$kueri=mysql_query($sqlnya,$konek);
}else{
echo I can't talk to the serverbr;
exit();
}
return $kueri;
}

}
?
/BODY
/HTML

Please keep telling me.

Thank you very much in advance.
ps: Thanks a lot too to Nathan Nobe and Robert Gegen for their responds...

On Wed, 15 Aug 2007 09:00:56 -0700
Jim Lucas [EMAIL PROTECTED] wrote:


A few missing pieces in your code.  Take a look below within your class.  I 
corrected it.

try also using include_once instead of require

and make sure that your error level and reporting are turned on so you can see 
what is happening.


Patrik Hasibuan wrote:

Dear my friends,

This is the first time for me to use OOP concept of PHP. I wrote still a very simple 
codes but it doesn't work as my manual book taught. the book titled MySQL/PHP 
Database Application by Jay Greenspan say these lines should work but in fact it 
don't work as expected.
Here is my code:
===
//pelangganbaru.php
?php
require koneksi.php;
$sqlnya=select country from countries;
$klas=new koneksi($sqlnya);
?
===
//koneksi.php
!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

HTML
HEAD
  META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see 
www.w3.org

/HEAD

BODY
?php
class koneksi{
$namakompie=127.0.0.1;

var $namakompie='127.0.0.1';

$un=root;

var $un='root';

$pw=mysqlpw;

var $pw='mysqlpw';

$sqlnya;

var $sqlnya;

$kueri;

var $kueri;

function koneksi($sqlnya){
echo superclass koneksi dipanggilbr;
$konek=mysql_connect($namakompie,$un,$pw);

$konek=mysql_connect($this-namakompie, $this-un, $this-pw);

if ($konek){
echo koneksi berhasil (connection succeeded)br;
$mybd=mysql_select_db(survey,$konek);
$kueri=mysql_query($sqlnya,$konek);
}else{
echo I can't talk to the serverbr;
exit();
}
return $kueri;
}

}
?
/BODY
/HTML
=

Theoritically if Class koneksi is being initialized than it prints koneksi 
berhasil (connection succeeded) but it doesn't.

Please tell me what is my mistake.

Thank you very much in advance.


--
Jim Lucas

Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
 by William Shakespeare

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

Re: [PHP] OOP in PHP

2007-08-15 Thread Patrik Hasibuan
Dear Jim,

thanks for your help. I've modified my codes as you adviced.
But than the output is:

superclass koneksi dipanggil
koneksi berhasil
No results found


The column 'country' of table 'countries' already really contents complete all 
contry name from all over the earth. How come the query of select country from 
countries results empty value. So I believe the problem is still on the my OOP 
programming because if I do the query only with the procedural concept the 
$kueri will content the complete record of the column country.

Please keep telling what is my mistake on my OOP PHP5 codes.
-
//pelangganbaru.php
?php
include_once koneksi.php;
$sqlnya=select * from countries;
$klas=new koneksi($sqlnya);
if ( mysql_num_rows($klas)  0 ) {
while( list($negara) = mysql_fetch_row($klas) ) {
echo negara-$negarabr;
}
} else {
echo 'No results found';
}
?
-
//koneksi.php
!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

HTML
HEAD
  META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 
2006), see www.w3.org

/HEAD

BODY
?php
class koneksi{
var $namakompie=127.0.0.1;
var $un=root;
var $pw=mysuccess;
var $sqlnya;
var $kueri;

function koneksi($sqlnya){
echo superclass koneksi dipanggilbr;
$konek=mysql_connect($this-namakompie,$this-un,$this-pw);
if ($konek){
echo koneksi berhasilbr;
$mybd=mysql_select_db(survey,$konek);
//$kueri=mysql_query($sqlnya,$konek);
$kueri=mysql_query($sqlnya,$konek) or die('MYSQL QUERY ERROR 
['.mysql_errno($konek).'] '.mysql_error($konek));
}else{
echo I can't talk to the serverbr;
exit();
}
return $kueri;
}

}
?
/BODY
/HTML
===
On Wed, 15 Aug 2007 13:13:18 -0700
Jim Lucas [EMAIL PROTECTED] wrote:

 Patrik Hasibuan wrote:
  Dear Jim,
  
  You've solved my problem, Jim. Thank you very much.
  
  Now, my code give the output as my expectation:
  
  superclass koneksi dipanggil
  koneksi berhasil
  negara-
  . 
  But come another problem, namely: the $negara is empty. I tried to read the 
  documentation on 
  
  http://www.php.net/manual/en/language.types.object.php#language.types.object.casting
  
  but I didn't manage to find the answer.
  
  I suspect the return $kueri could be only for 'returning' a variable of 
  boolean or string or number but not 'returning' an array (such as the 
  result of mysql_query(select country from countries,$koneksi) ) or an 
  object (such as the result of mysql_connect() ).
  
  So how should I get the content of mysql_query() so I can get the value 
  with mysql_fetch_row() or inherit array?
  Is is also possible to re-use the result of mysql_connect() or inherit 
  the $konek?
  
  Here is my current code:
  
  //pelangganbaru.php
  ?php
  include_once koneksi.php;
  $sqlnya=select country from countries;
  $klas=new koneksi($sqlnya);
 
 Try this instead
 
 if ( mysql_num_rows($klas)  0 ) {
   while( list($negara) = mysql_fetch_row($klas) ) {
   echo option value=\$negara\$negara/option;
   }
 } else {
   echo 'No results found';
 }
 
 And within your class change your mysql_query line to this
 
 $kueri=mysql_query($sqlnya,$konek) or die('MYSQL QUERY ERROR 
 ['.mysql_errno($konek).'] 
 '.mysql_error($konek));
 
 This will make the system fail and kill the script if the query fails for 
 some reason.
 The die() part will then print the error number and what mysql thinks is 
 wrong.
 
 This isn't the best way to use error reporting in a production system, but 
 since you are new at 
 this, this is a simple way to do error reporting.
 
 It is always a good idea to use is_resource($resource_handle_from_mysql) as a 
 test to see if you did 
 in fact get a valid resource id from the mysql_connect() call.
 
 
  $brs=mysql_fetch_row($klas-kueri);
  list($negara)=$brs;
  echo option value=\$negara\$negara/option;
  
  ?
  =
  //koneksi.php
  !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
  
  HTML
  HEAD
META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 
  2006), see www.w3.org
  
  /HEAD
  
  BODY
  ?php
  class koneksi{
  var $namakompie=127.0.0.1;
  var $un=root;
  var $pw=mysuccess;
  var $sqlnya;
  var $kueri;
  
  function koneksi($sqlnya){
  echo superclass koneksi dipanggilbr;
  $konek=mysql_connect($this-namakompie,$this-un,$this-pw);
  if ($konek){
  echo koneksi berhasilbr;
  $mybd=mysql_select_db(survey,$konek);
  $kueri=mysql_query($sqlnya,$konek);
  }else{
  echo I can't talk to the serverbr;
  exit();
  }
  return $kueri;
  }
  
  }
  ?
  /BODY
  /HTML
  
  Please keep telling me.
  
  Thank you very much in advance.
  ps: Thanks a lot too to Nathan Nobe and Robert Gegen for their responds...
  
  On Wed, 15 Aug 2007 09:00:56 -0700
  Jim Lucas [EMAIL PROTECTED] wrote:
  
  A few missing pieces in your code.  

Re: [PHP] OOP in PHP

2007-08-15 Thread Jim Lucas

Patrik Hasibuan wrote:

Dear Jim,

thanks for your help. I've modified my codes as you adviced.
But than the output is:

superclass koneksi dipanggil
koneksi berhasil
No results found


The column 'country' of table 'countries' already really contents complete all contry name from all over the 
earth. How come the query of select country from countries results empty value. So I believe the 
problem is still on the my OOP programming because if I do the query only with the procedural 
concept the $kueri will content the complete record of the column country.

Please keep telling what is my mistake on my OOP PHP5 codes.
-
//pelangganbaru.php
?php
include_once koneksi.php;
$sqlnya=select * from countries;

ok, don't know why it took me this long to realize what the problem is.

The following line will return the object of a the class that you are initializing, not the result 
set pointer.


So, what you need to do is this

Change this

function koneksi($sqlnya){
...
}

to this

function getkoneksi($sqlnya) {
...
}

Then this
$klas=new koneksi($sqlnya);
to this
$o = new koneksi();
$klas = $o-get_koneksi($sqlnya);

Now all should work.


$klas=new koneksi($sqlnya);
if ( mysql_num_rows($klas)  0 ) {
while( list($negara) = mysql_fetch_row($klas) ) {
echo negara-$negarabr;
}
} else {
echo 'No results found';
}
?
-
//koneksi.php
!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

HTML
HEAD
  META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see 
www.w3.org

/HEAD

BODY
?php
class koneksi{
var $namakompie=127.0.0.1;
var $un=root;
var $pw=mysuccess;
var $sqlnya;
var $kueri;

function koneksi($sqlnya){
echo superclass koneksi dipanggilbr;
$konek=mysql_connect($this-namakompie,$this-un,$this-pw);
if ($konek){
echo koneksi berhasilbr;
$mybd=mysql_select_db(survey,$konek);
//$kueri=mysql_query($sqlnya,$konek);
$kueri=mysql_query($sqlnya,$konek) or die('MYSQL QUERY ERROR 
['.mysql_errno($konek).'] '.mysql_error($konek));
}else{
echo I can't talk to the serverbr;
exit();
}
return $kueri;
}

}
?
/BODY
/HTML
===
On Wed, 15 Aug 2007 13:13:18 -0700
Jim Lucas [EMAIL PROTECTED] wrote:


Patrik Hasibuan wrote:

Dear Jim,

You've solved my problem, Jim. Thank you very much.

Now, my code give the output as my expectation:

superclass koneksi dipanggil
koneksi berhasil
negara-
. 
But come another problem, namely: the $negara is empty. I tried to read the documentation on 


http://www.php.net/manual/en/language.types.object.php#language.types.object.casting

but I didn't manage to find the answer.

I suspect the return $kueri could be only for 'returning' a variable of boolean or 
string or number but not 'returning' an array (such as the result of mysql_query(select 
country from countries,$koneksi) ) or an object (such as the result of mysql_connect() ).

So how should I get the content of mysql_query() so I can get the value with 
mysql_fetch_row() or inherit array?
Is is also possible to re-use the result of mysql_connect() or inherit the 
$konek?

Here is my current code:

//pelangganbaru.php
?php
include_once koneksi.php;
$sqlnya=select country from countries;
$klas=new koneksi($sqlnya);

Try this instead

if ( mysql_num_rows($klas)  0 ) {
while( list($negara) = mysql_fetch_row($klas) ) {
echo option value=\$negara\$negara/option;
}
} else {
echo 'No results found';
}

And within your class change your mysql_query line to this

$kueri=mysql_query($sqlnya,$konek) or die('MYSQL QUERY ERROR ['.mysql_errno($konek).'] 
'.mysql_error($konek));


This will make the system fail and kill the script if the query fails for some 
reason.
The die() part will then print the error number and what mysql thinks is wrong.

This isn't the best way to use error reporting in a production system, but since you are new at 
this, this is a simple way to do error reporting.


It is always a good idea to use is_resource($resource_handle_from_mysql) as a test to see if you did 
in fact get a valid resource id from the mysql_connect() call.




$brs=mysql_fetch_row($klas-kueri);
list($negara)=$brs;
echo option value=\$negara\$negara/option;

?
=
//koneksi.php
!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

HTML
HEAD
  META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see 
www.w3.org

/HEAD

BODY
?php
class koneksi{
var $namakompie=127.0.0.1;
var $un=root;
var $pw=mysuccess;
var $sqlnya;
var $kueri;

function koneksi($sqlnya){
echo superclass koneksi dipanggilbr;
$konek=mysql_connect($this-namakompie,$this-un,$this-pw);
if ($konek){
echo koneksi berhasilbr;
$mybd=mysql_select_db(survey,$konek);
$kueri=mysql_query($sqlnya,$konek);
}else{
echo I can't 

Re: [PHP] OOP in PHP

2007-08-15 Thread Jim Lucas

Jim Lucas wrote:

Patrik Hasibuan wrote:

Dear Jim,

thanks for your help. I've modified my codes as you adviced.
But than the output is:

superclass koneksi dipanggil
koneksi berhasil
No results found


The column 'country' of table 'countries' already really contents 
complete all contry name from all over the earth. How come the query 
of select country from countries results empty value. So I believe 
the problem is still on the my OOP programming because if I do the 
query only with the procedural concept the $kueri will content the 
complete record of the column country.


Please keep telling what is my mistake on my OOP PHP5 codes.
-
//pelangganbaru.php
?php
include_once koneksi.php;
$sqlnya=select * from countries;

ok, don't know why it took me this long to realize what the problem is.

The following line will return the object of a the class that you are 
initializing, not the result set pointer.


So, what you need to do is this

Change this

function koneksi($sqlnya){
...
}

to this

function getkoneksi($sqlnya) {


oops this should be get_koneksi($sqlnya)


...
}

Then this
$klas=new koneksi($sqlnya);
to this
$o = new koneksi();
$klas = $o-get_koneksi($sqlnya);

Now all should work.



--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] OOP in PHP

2007-08-15 Thread Patrik Hasibuan
Dear my friend, Jim Lucas.

Thank you very much for your help. You've solved my problem one more time.

I really appreciate your help.
===
On Wed, 15 Aug 2007 14:17:02 -0700
Jim Lucas [EMAIL PROTECTED] wrote:

 Jim Lucas wrote:
  Patrik Hasibuan wrote:
  Dear Jim,
 
  thanks for your help. I've modified my codes as you adviced.
  But than the output is:
  
  superclass koneksi dipanggil
  koneksi berhasil
  No results found
  
 
  The column 'country' of table 'countries' already really contents 
  complete all contry name from all over the earth. How come the query 
  of select country from countries results empty value. So I believe 
  the problem is still on the my OOP programming because if I do the 
  query only with the procedural concept the $kueri will content the 
  complete record of the column country.
 
  Please keep telling what is my mistake on my OOP PHP5 codes.
  -
  //pelangganbaru.php
  ?php
  include_once koneksi.php;
  $sqlnya=select * from countries;
  ok, don't know why it took me this long to realize what the problem is.
  
  The following line will return the object of a the class that you are 
  initializing, not the result set pointer.
  
  So, what you need to do is this
  
  Change this
  
  function koneksi($sqlnya){
  ...
  }
  
  to this
  
  function getkoneksi($sqlnya) {
 
 oops this should be get_koneksi($sqlnya)
 
  ...
  }
  
  Then this
  $klas=new koneksi($sqlnya);
  to this
  $o = new koneksi();
  $klas = $o-get_koneksi($sqlnya);
  
  Now all should work.
  
 
 -- 
 Jim Lucas
 
 Some men are born to greatness, some achieve greatness,
 and some have greatness thrust upon them.
 
 Twelfth Night, Act II, Scene V
  by William Shakespeare
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


-- 
Patrik Hasibuan [EMAIL PROTECTED]
Junior Programmer

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



Re: [PHP] OOP slow -- am I an idiot?

2006-11-08 Thread Stut

Stut wrote:
This is a question of design, not a question of whether to use OOP. 
For example, in several of the sites I maintain I have classes that 
inherit from a base class called Table. The base class provides a lot 
of the basic methods for working on a table (think ActiveRecord). It 
also has static methods for doing things like updates and deletes 
based on a where clause. The derived classes can override filter 
methods (AfterLoad and BeforeSave) to massage the data after it's 
loaded and before it's saved. They also add any methods needed for 
acting on that particular entity.


I'm the first to admit that OOP is not always the best methadology to 
use - the 'best methadology for all situations' does not exist. 
However, the general feeling people will get towards OOP from this 
list seems to be 'OOP bad, anything else better'. OOP is great as long 
as you follow OOD principles and have a fair amount of common sense. 
It should not be used just because it's there, but it should also not 
be dismissed.


In fact, in writing that I've just realised that OOP is not the key... 
OOD is. OOD can be applied (with no syntax or compiler assistance) in 
a functional system which will have great benefits, all of which I 
think most people are aware of but, for whatever reason, fail to 
adequately apply - which is where OOP can be useful since it enforces 
the structure and protection through the syntax (PHP4 sucked for this, 
PHP5 is better).


When you actually think about it, OOP is not a methadology - it's a 
syntax. OOD is the methadology. Ramble... ramble... ramble... over!


I know this is a fairly old thread, but I thought people might be 
interested in reading a write-up I've recently finished regarding my 
Table class and it's usage. I had been intending to write it for a 
while, but a request from Ed Lazor kicked me into actually doing it. 
Don't expect the quality to be too high - I'm more used to writing 
requirement/functional specs and user documentation than this type of thing.


   http://stut.net/articles/php_models.html

All comments are welcome, both on the article and on the code itself. 
However, please keep on-list replies to the code!


-Stut

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



Re: [PHP] Solution: [PHP] OOP slow -- am I an idiot?

2006-10-16 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-15 13:59:39 -0700:
 As I cannot think of a class-based way to build my report, I think
 I'll use a customer class everywhere BUT in the report.  Inside the
 report I'll just use one SQL statement instead of dozens
 of instances and hundreds of queries.
 
 I'll make a note inside the class that this and that method is not the
 only place the data is accessed, to also check inside the report.
 
 Sometimes, you've just gotta compromise to get the job done.  Most of
 the time, OOP is a good idea, but in this instance I don't think it's
 the best choice.
 
You're suffering because you're putting code that belongs in
a separate layer (data source) in the domain logic layer.
Don't blame classes for shortcomings in your design.

http://www.martinfowler.com/articles/dblogic.html

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



[PHP] Solution: [PHP] OOP slow -- am I an idiot?

2006-10-15 Thread Chris de Vidal
As I cannot think of a class-based way to build my report, I think I'll use a 
customer class
everywhere BUT in the report.  Inside the report I'll just use one SQL 
statement instead of dozens
of instances and hundreds of queries.

I'll make a note inside the class that this and that method is not the only 
place the data is
accessed, to also check inside the report.

Sometimes, you've just gotta compromise to get the job done.  Most of the time, 
OOP is a good
idea, but in this instance I don't think it's the best choice.

It's less elegant but more pragmatic.  Our project is medium-sized (only about 
10K lines) and this
will work just fine.  (It makes me wonder if enterprise-class OO projects had 
to make the same
decisions.)


Thanks to everyone for your input.  I need to unsubscribe from the list, so if 
you have any input,
please CC: Chris (AT) deVidal (DOT) tv (my real email address).  You might get 
an automatic reply,
click the link.

CD

Think you're a good person?  Yeah, right!  ;-)
Prove it and get ten thousand dollars:
TenThousandDollarOffer.com

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-14 Thread Tony Marston

Stut [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Tony Marston wrote:
 Stut [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]

 My general approach to designing a system is data-centric. I tend to 
 start by defining the database schema since getting that clear in my 
 head tends to lead me to a decent design.


 What a coincidence! That's exactly my approach, but I've taken it one 
 step further. I always start with a properly normalised database which I 
 can then import into my daa dictionary application. From there I can 
 press a button and create a class file for each database table, and I am 
 ptting the finishing touhes to a procedure whereby I can press another 
 button to generate the scripts which will maintain each table. This means 
 I can get basic transactions up and running without writing a single line 
 of code. All I have to do is edit these files to include business logic 
 and any customisations.

 This level of automation is not possible with some people's OO 
 implementations, so I can only conclude that their approach is not the 
 optimal one.


 Youch!! Your implementation seems to be focused on development efficiency 
 rather than runtime efficience.

Precisely. That is why I said it was adminstrative web applications which 
typically have far fewer users than web sites.

 In all but rare research projects this is backwards for a web-based 
 system.

Wrong again. This is for administrative web applications, the type that were 
previously built as desktop applications. Their function is to get data into 
and out of a database i.e. CRUD applications), not to serve thousands of 
casual vuisitors.

 This is exactly the practice I am trying to discourage. It's a well-known 
 fact that code generators are a poor substitute for real developers.

It depends how you go about it. My code generators fulfil the basics, then 
the programmer's job is to customise it.

 For most projects I don't start out with OOP in mind, but my brain is 
 used to building OOP-style systems so nearly everything I do ends up 
 with a few classes.


 The difference with me is that I don't waste my time with trivial 
 websites, I concentrate on administrative web applications. But even when 
 I wrote the code for my own website at http://www.radicore.org I still 
 used all my database classes as it was far easier than doing it the 
 traditional old-fashioned way

 Trivial websites are where you can get away with using code generators. 
 For anything non-trivial I would not feel comfortable with a 
 jack-of-all-trades-master-of-none-style of code. Now that I think of it 
 I'm quite anal about the quality of my code, so I don't think I'd ever use 
 a code generator - never have before.

I have never liked any of the code generators I have seen created by others, 
but with my general-purpose framework I noticed that a lot of the code that 
I was generating by hand followed a familiar pattern. It was then a simple 
exercise to write a program to generate this same code on command.

Be aware that I am not attempting to generate *all* the code that an 
application will need, just the basics to  get it functioning. This takes 
all the drudgery out of the job and leaves the programmer to do the 
interesting bits.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org 

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-14 Thread Tony Marston

Stut [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Ed Lazor wrote:
 On Oct 12, 2006, at 4:36 PM, Stut wrote:
 If I then go on to create an admin interface for the users, I would 
 create another completely separate class called UserCollection to handle 
 more than one user. I may at that point choose to expose any 
 data-massaging methods in User to UserCollection to avoid code 
 duplication, but that would be the extent of the way UserCollection uses 
 the User class since the User class is optimised to work on a single 
 user at any one time.

 We use a similar approach for the user class.  I haven't ever implemented 
 something like the UserCollection class though.  I'm curious about that. 
 Does your UserCollection class extend the basic user class?  Or is it 
 something else entirely; I dunno, maybe UserCollection has a property 
 defined as an array of User class?  I think that's what people were 
 saying earlier in the thread as being a very bad thing in terms of 
 memory utilization, etc.

 Indeed, that would be a very bad thing, unless you've already considered 
 that. I've previously mentioned that I have an ActiveRecord-style 
 implementation for a lot of my DB access. The base class for that system 
 has a static function called FindAll which will return an array of 
 objects. However, it only does a single SQL statement. The base class also 
 has a method LoadFromArray which, shockingly, loads the object from an 
 array. This means that from a single DB request I can get an array of 
 objects each representing one entitity (potentially a row, but not 
 necessarily).

The very idea of one object per row makes me want to throw up. I have one 
object per table, and each object can deal with any number of rows. I don't 
use getters and setters to access the columns from any row, I simply input 
an array (typically one row from the $_POST array) and output an array which 
may contain any number of rows. I find this to be far easier and no less 
efficient.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-14 Thread Tony Marston

Ed Lazor [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 On Oct 13, 2006, at 1:35 AM, Tony Marston wrote:
 What a coincidence! That's exactly my approach, but I've taken it  one 
 step
 further. I always start with a properly normalised database which I  can 
 then
 import into my daa dictionary application. From there I can press a 
 button
 and create a class file for each database table, and I am ptting the
 finishing touhes to a procedure whereby I can press another button to
 generate the scripts which will maintain each table. This means I  can 
 get
 basic transactions up and running without writing a single line of  code. 
 All
 I have to do is edit these files to include business logic and any
 customisations.

 Is the Radicore framework still available?

What do you mean *still*? Since I released it I have never closed it down. I 
am still working on it and releasing improvements. I am just about to 
release some new functionality which will generate more standard code for 
each transaction. Watch my website (see link in my signature) for an 
announcement.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org 

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-14 Thread Tony Marston

Ed Lazor [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 On Oct 13, 2006, at 1:54 AM, Stut wrote:
 Youch!! Your implementation seems to be focused on development 
 efficiency rather than runtime efficience. In all but rare research 
 projects this is backwards for a web-based system. This is exactly  the 
 practice I am trying to discourage. It's a well-known fact that  code 
 generators are a poor substitute for real developers.

 I agree with Stut, but I'd also like to check out a copy of the 
 framework.  It seems like a lot of people are using frameworks now  days 
 and I can't help but wonder if they provide similar performance  as the 
 OOP library that Stut uses.

If you want to build administrative web applications which have a small 
number of users, and where development costs are more important than 
performance of execution (i.e. developer cycles over cpu cycles) then check 
out RADICORE at http://www.radicore.org It is better than Ruby on Rails.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org 

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-13 Thread Stut
Please include the list when replying to that others may benefit (or 
suffer) from the discussion.


Bruce Cowin wrote:

I like your static user class.  Does the user instance then get saved to a 
session variable that is serialized/unserialized on every page?
  


There is no user instance as such. In that simple case the only thing 
stored is an array of allowable actions. If I were to extend it to more 
complex user system I would likely convert the User class to non-static 
and store an instance of that in the session. I would then have a static 
method called Current() to return the static instance.


-Stut

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-13 Thread Stut
 that, it doesn't apply too much where PHP is concerned 
unless you are developing a set of classes for public consumption. 
What is more important is that by packaging data and logic together 
you end up with one place where it all happens, and you can choose 
how much of the internal workings are exposed to the rest of the system.


The only difference here is that I'd probably aim for all classes to 
be good enough for public consumption, but I know that takes more time 
in development.


For me it's not a case of taking more time in development. Due to the 
nature of PHP, the way a particular class is used, its context, is more 
important to me than making it generic. I'll advocate code reuse until 
I'm blue in the face, but when performance is one of the main goals 
there is often little choice but to rewrite code to fit a particular 
situation. This is one of the reasons I steer clear of libraries like 
PEAR for anything but trivial sites - I can't guarantee that third party 
code will not adversely affect the overall performance of the site. In 
addition I've found that 9 times out of 10 it's quicker in the long run 
to just implement it myself - at least then I know exactly what it's 
doing and how, which makes it easier to fix and optimise later.


To relate that twoddle to PHP... OOP is a stable, mature methodology. 
However, OOP in PHP is fairly new (if you ignore PHP4's pitiful 
efforts) and there's still a lot of unease about this new kid on the 
block, along with a lot of hype around the idea that it will launch 
PHP into being a real programming language instead of just a 
web-based toy (can't recall where I read that, otherwise I'd 
provide a reference).


Yea, that's why I was making sure to get PHP5.  It seems like 
providers are still lagging in implementing it tho?


If by providers you mean hosts then you're right. I actually run a 
hosting company and can only offer PHP5 because we recently went through 
a process of upgrading all our servers (painful that was!!) and a 
customer survey showed that over 90% of them wanted the upgrade - 13% 
said they were likely to switch provider within 6 months if we did not 
upgrade.


However, I do know that making such a move can be incredibly expensive, 
not only in obvious engineer time required to simply do the upgrade but 
the resulting support costs will be an order of magnitude greater even 
if the upgrades themselves go very smoothly.


I'm in a very fortunate position in that nearly all of my clients fall 
into one of two camps... those that are competent developers, and those 
with simple static sites.


I'd quite like an opinion from a Zend Engine developer here. As I've 
previously mentioned I primarily work with a fairly large OOP-based 
system but haven't noticed any great performance drain. While it's 
true that we use Zend Platform on both our development and production 
servers that's purely due to the sheer number of files involved in 
each request - something that would still be a problem if it were 
100% procedural. And even without the platform enabled it's not 
particularly sluggish.


Are you at liberty to talk more about the OOP-based system you use?  
It is a PHP developer sweet or something?  I've seen a few, but I've 
never used them.


I don't use any third party code unless it's something I cannot 
implement or don't have the time to implement - both of which are 
thankfully quite rare. PHP frameworks are great if you want rapid 
development and your system fits nicely into the common structure, but 
they suck arse if you want to do anything even slightly different.


I actually use two different code structures - one at my day job which I 
can't say too much about (except that it's a mess by way of much 
incremental development), and the one I use for most of my 
personal/business sites. I'm currently writing an article describing the 
latter - I'll post a link to this list when it's finished if people are 
really interested.


-Stut

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-13 Thread John Wells

On 10/13/06, Stut [EMAIL PROTECTED] wrote:

Ed Lazor wrote:
 ...Or is it something else entirely; I dunno, maybe
 UserCollection has a property defined as an array of User class?  I
 think that's what people were saying earlier in the thread as being a
 very bad thing in terms of memory utilization, etc.


I'm honestly having a difficult time thinking of any way *other* than
having an array of User objects.  In previous projects I've tried the
route of (like Richard mentioned early on):

class Customers {
   var $ids = array();
   var $names = array();
}

But found it very cumbersome and unintuitive when dealing with a
single Customer.  Moreso I got lost when I didn't know if I were
dealing with one or many customers...

As soon as I went to a Customer and CustomerCollection approach, I was
able to make sense of it all.  Even though CustomerCollection usually
didn't actually exist, except conceptually as an array of Customer
objects within my application code.  Like Stut suggested, I too have
static fetch functions derived from the base ActiveRecord class that
return arrays of objects.

Maybe all of my applications have been simple enough in that I
tended to work on single objects 95% of the time, and therefore
creating interfaces for those single objects made sense.  I think
that's what Ed means by situational?

It is occuring to me that perhaps all of my bias is centered around
the fact that I always create my models as children of an ActiveRecord
class, which is by nature based on *one record* of a table.

Is there an ActiveTable class that, if implemented, might completely
change everything???

Until then, I'm not convinced: constructing a basic building block
such as a Customer, and then an aggregate block such as a collection
of Customers, and so on, seems the most stable and scalable approach
almost without exception...and perhaps, with that, I'm revealing the
extent of my OOP naivety...

John W

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-13 Thread Ed Lazor


On Oct 13, 2006, at 1:35 AM, Tony Marston wrote:
What a coincidence! That's exactly my approach, but I've taken it  
one step
further. I always start with a properly normalised database which I  
can then
import into my daa dictionary application. From there I can press a  
button

and create a class file for each database table, and I am ptting the
finishing touhes to a procedure whereby I can press another button to
generate the scripts which will maintain each table. This means I  
can get
basic transactions up and running without writing a single line of  
code. All

I have to do is edit these files to include business logic and any
customisations.


Is the Radicore framework still available?

-Ed

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-13 Thread Ed Lazor


On Oct 13, 2006, at 1:54 AM, Stut wrote:
Youch!! Your implementation seems to be focused on development  
efficiency rather than runtime efficience. In all but rare research  
projects this is backwards for a web-based system. This is exactly  
the practice I am trying to discourage. It's a well-known fact that  
code generators are a poor substitute for real developers.


I agree with Stut, but I'd also like to check out a copy of the  
framework.  It seems like a lot of people are using frameworks now  
days and I can't help but wonder if they provide similar performance  
as the OOP library that Stut uses.


-Ed

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-12 06:49:22 +0100:
 Roman Neuhauser wrote:
 # [EMAIL PROTECTED] / 2006-10-11 21:28:36 +0100:
 Richard Lynch wrote:
 This is a classic example of the obvious OOP solution being wildly
 inappropriate.
 Ok, so I now find myself in the unusual position of disagreeing with the 
 Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP is 
 all about.

[...]

 I never said anything about physical entities. The OOP methodology has 
 nothing to do with physical entities, but it has everything to do with 
 entities. The fact that in this example the entity is physical has no 
 bearing on it whatsoever. Nobody said anything about limiting OOP 
 entities to physical entities.

Right, sorry for going off on a tangent, it was 3am. :]
 
 When you're talking about something as simple as a customer it's true 
 that an OOP approach probably doesn't add much to the equation. However, 
 when you're dealing with complex entities which span several tables and 
 have data stored in a different format to how it's used (think 
 serialize) it makes sense to have a single point where you can get that 
 data so that you don't end up duplicating the code needed to extract and 
 store it.

I'll have most of that handled by the database through triggers,
updatable views, foreign keys etc.
 
 If this is not what you think OOP is all about, do please enlighten us 
 as to the error of our ways.
 
 Imagine deleting many rows in a table one by one (pseudocode):
 snip
 instead of taking them with a single DELETE:
 snip
 
 Whoa nellie!! This is a question of design, not a question of whether to 
 use OOP.

Sure. I think obvious is the key word in Richard's statement:

 This is a classic example of the obvious OOP solution being wildly
 inappropriate.

AFAICS he says that the obvious solution is wrong, not that OOP
is wrong here.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Tony Marston

Roman Neuhauser [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
# [EMAIL PROTECTED] / 2006-10-11 21:28:36 +0100:
 Richard Lynch wrote:
 On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote:
 I want to create a customer class which fetches its attributes from
 a MySQL database.
 
 No, you don't. :-)
 
 This is a classic example of the obvious OOP solution being wildly
 inappropriate.

 Ok, so I now find myself in the unusual position of disagreeing with the
 Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP is
 all about.

I have to disagree as well. There is absolutely nothing wrong which the 
approach of creating one class for each table in the database. It cannot be 
wrong for the simple reason THAT IT WORKS! It is also the simplest approach 
as it keeps all the business rules for each database entity in a single 
class. Also, by keeping the structure of each object in sync with the 
structure of the database you don't have to introduce another pointless 
level of complexity with OR mappers.

Those OO purists who insist on creating object hierarchies which bear no 
resemblance to the database structure are making a rod for their own backs. 
That notion of purity is my idea of putrefaction.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org 

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Chris de Vidal
By the way, about myself.  I'm primarily a system administrator.  Most of the 
time I USE code, NOT
write it.  But I also dabble, and right now we need to improve our old custom 
PHP revenue
application which has sat stagnant for a few years.  We can't afford a 
full-time programmer and I
know enough to be dangerous ;-)  So I'm the guy.

All that to say I'm no pro and am humbly asking your collective professional 
opinions.


--- Richard Lynch [EMAIL PROTECTED] wrote:
  I want to create a customer class which fetches its attributes from
  a MySQL database.
 
 No, you don't. :-)
 
 This is a classic example of the obvious OOP solution being wildly
 inappropriate.

I'll consider that possibility.


 Start thinking more in terms of what you want the whole application to
 do, and build classes that do THAT, rather then starting with a single
 customer and their info.

It seems you are advocating procedural programming here.  I don't see how your 
use of classes are
anything more than glorified functions.  I could re-word the sentence above 
thusly:

 Start thinking more in terms of what you want the whole application to
 do, and build [functions] that do THAT...

That's the path we went down at first and the net result was data access 
functions being copied
and modified all over the place, making maintenance a real chore.

Did it have speed?  Yes.  Do I hesitate to make changes to it?  Yes.  In a 
world where I am forced
to choose between speed and maintainability, I'll probably choose speed, 
particularly when the
program will be used daily.  However, I truly believe a speedier OOD is 
attainable, which is why
I'm asking.


If, however, you are talking about some blending, where I create a 
procedural-style class and then
make any modifications in subclasses which override the parent class, like this:
class parentFunction
{
getRevenueForCustomer ($id)
{
// SELECT * FROM customer_revenue WHERE customer_id = '$id'
}
}

class childFunction inherits parentFunction
{
// Overriding the parent function
getRevenueForCustomer ($id, $year, $month, $department)
{
// SELECT * FROM customer_revenue WHERE customer_id = '$id' AND year = 
'$year' AND month =
'$month' AND department = '$department'
}
}


If that's what you mean, I honestly can't see how that saves coding time or 
helps maintenance,
unless I need to also use some extraneous code with every query which would be 
included into the
constructor.  But then I could also use a function (instead of a class) which 
is like a query
wrapper:
function sql_query ($query)
{
// Some massaging routines
// ...
// Some more
// ...

$result = mysql_query ($query);

// Error handling routines
// ...

// Other routines
// ...

return $result;
}

sql_query (SELECT * FROM ...);


If that's the case, I don't see the need for classes at all, and that's 
actually the path we went
down at first.  We created a query function which massaged the input and 
handled errors.  I've
since learned that's not what I really wanted to do; I want to handle errors 
elsewhere.  I think
the above is easier to understand than using a class.


Anyway, tell me what you have in mind.

CD

Think you#39;re a good person?  Yeah, right!  ;-)
Prove it and get ten thousand dollars:
TenThousandDollarOffer.com

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Richard Lynch
On Wed, October 11, 2006 3:28 pm, Stut wrote:
 Richard Lynch wrote:
 On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote:
 I want to create a customer class which fetches its attributes
 from
 a MySQL database.

 No, you don't. :-)

 This is a classic example of the obvious OOP solution being wildly
 inappropriate.

 Ok, so I now find myself in the unusual position of disagreeing with
 the
 Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP
 is
 all about.

 You can encapsulate everything to do with a customer in an object.
 This
 ensures that you don't duplicate any code that works on customer data.
 You avoid duplication of code. As a result you can ensure data
 integrity
 because there is only one route to read and write it.

 If this is not what you think OOP is all about, do please enlighten us
 as to the error of our ways.

Doing this without some kind of cache or some kind of bulk load of
multiple customer data is inevitably going to lead to having a zillion
customer instances floating around in one script to calculate
something not readily expressed in an SQL aggregate.

See other thread regarding 100 orders with all related uploaded files
for an example.

It's not so much that having a customer object is wrong, as that
having ONLY a customer object to deal with an application that deals
with MUCH MORE than a single customer at a time is wrong.

You're going to end up having a TON of duplicate code for a single
customer and multiple customers, or you're going to swamp your machine
with way too many instances of a do-nothing object for the sake of
being OOP

And, in point of fact, unless you spend the majority of your
time/energy in your application dealing with one customer at a time,
it's quite likely that your one customer at a time can be encapsulated
in a much more re-usable generalized notion of a set of customers --
albeit a set with only one element, and with a few specialized
functions for certain operations with only work for one-element sets.

Objectifying customer is the immediate, obvious, and totally
inappropriate solution to needing to deal with not just one customer,
but with sets of customers, some of which may, or may not, need
special handling for a set with one element.

This is merely the most obvious example of what is *probably* the
needs of the original poster.

One problem with OOP is that you really do need to understand very
very very well the full scale and scope of your application before you
can architect the appropriate OOP model.

Its entirely possible that he does not need sets of customers, but
needs some OTHER OOP model -- And there's no way to know without
knowing the full scope of the project.

You can do a bunch of simple object stuff in an iterative design,
scale, scope interaction for rapid prototyping, but you have to be
prepared to scrap all that code once you figure out what you REALLY
wanted to do for your application, and you build the REAL application
with the correct OOP model.

Some Free Advice for a beginning OOP scripter.

#1. Play around a lot with OOP on some non-mission-critical toy
projects to get the feel of it.  Build the smallest silliest OOP thing
you can think of, and push the limits of class inheritence and how the
pieces can be fit together in unusual ways.

#2. Don't use a 'class' in a real project until you find yourself
typing code that does almost the same thing as code you typed before,
only it's just enough different to make an include or function
unwieldy.  At that juncture in time, figure out how you could relate
the code you are typing NOW to the old code, and what common
components you can abstract out to a base class and which parts are
specializations of the base class.  Re-code both chunks of code as
OOP.  *THAT* is the real power of OOP.

Don't get me wrong:  There are some other other uses of OOP, such as a
substitute for namespaces for code for public release.  But the
obvious one-to-one mapping of real-world things to OOP classes
seldom works out very well, unless your whole application is all about
exploring/defining the relationships among those objects, rather than
doing something complex with those objects.

I *still* don't see OOP as a Right Answer for spitting out HTML web
pages in optimized minimalist time frames...

Maybe my brain just got warped by all that AI/Lisp work I did for a
couple decades, but it feels to me like a bad selection of weapons for
the task at hand, most times I see it in PHP. [shrug]

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Richard Lynch
On Thu, October 12, 2006 12:49 am, Stut wrote:
 Roman Neuhauser wrote:
 # [EMAIL PROTECTED] / 2006-10-11 21:28:36 +0100:
 Richard Lynch wrote:
 On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote:
 I want to create a customer class which fetches its attributes
 from
 a MySQL database.
 No, you don't. :-)

 This is a classic example of the obvious OOP solution being
 wildly
 inappropriate.
 Ok, so I now find myself in the unusual position of disagreeing
 with the
 Lynchmeister. Why is this wildly inappropriate? IMHO this is what
 OOP is
 all about.

To clarify my original statement.

The *OBVIOUS* OOP setup of customer === class customer was the wildly
in appropriate bit, not using OOP in some more sensible manner, like:

//a set of customers
class customers (
  var customer_ids array();
}

I believe my original post went on to say that more explicitly, but I
can now see that many thought I was just railing against OOP in
general, which was not my intent.  (In *this* particular sentence,
anyway. :-))

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Richard Lynch
On Thu, October 12, 2006 3:11 am, Tony Marston wrote:
 I have to disagree as well. There is absolutely nothing wrong which
 the
 approach of creating one class for each table in the database. It
 cannot be
 wrong for the simple reason THAT IT WORKS!

Only problem is that then you often end up making ONE INSTANCE for
each *row* in a large result set, and then you are in BIG TROUBLE.

IT DOES NOT WORK!

You've *got* to have some kind of other class that handles more than a
couple handsful of the data, for anything other than a trivial
application.

And if it was trivial to start with OOP is rarely the right answer.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Richard Lynch
On Thu, October 12, 2006 8:24 am, Chris de Vidal wrote:
 [use the archives]
I can't architect a good OOP solution to a problem that hasn't been
fully defined, any more than one can architect a house without knowing
all the rooms that are needed...

I agree that all the code samples you provided below are wrong, if
that helps. :-)

If getRevenueForCustomer is all you need, then I'd have optional args
for year and other factors, and have just one query and one function,
and it does the right thing for that one customer.

I'm assuming you need a heck of a lot more than that, though, so the
above paragraph is not particularly helpful.

The problem with an OOP discussion like this is that you have to have
a complete understanding of what needs to be done before you can make
sensible statement about what do do.

It's POSSIBLE that class customer is the right answer, though I
doubt it based on your original post about performance problems from
having too many instances floating around.

Maybe others' analysis that class customer was right, but not having
the database access optimized with cache or with aggregators or
something was the true problem.

Maybe I even have a point about using class customers and operating
on sets, even if it means specializing on the one-element-set.

There's no way anybody can say for sure, not knowing the full scope of
the application, though.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Ed Lazor


On Oct 12, 2006, at 10:18 AM, Richard Lynch wrote:

I can't architect a good OOP solution to a problem that hasn't been
fully defined, any more than one can architect a house without knowing
all the rooms that are needed...


Sorry to jump into the middle of the conversation, but I thought this  
was a pretty interesting comment.  It serves as one of those  
occasional reminders that I need to go back and study OOP structure  
design a bit more.  I know you're right about the importance of a  
fully defined problem, but it also seems that the reverse is true if  
you're really good with OOP.  In other words, it seems like any high  
quality solution starts by defining least common denominators.  You  
start with basic building blocks and expand from there; I'm always  
amazed when I see space stations or other complex structures built  
out of Legos, for example.  My problem is that I usually look at OOP  
and think it'll take too long, so I go the non-OOP route, solve the  
problem, and move on.  I can't help but think I'm missing out.  I do  
have libraries of code that I reuse, but I've always heard that I'd  
benefit a lot more from them if I OOPed them.  Dunno...  that's my  
two cents worth anyway hehe


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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Stut

Richard Lynch wrote:

I *still* don't see OOP as a Right Answer for spitting out HTML web
pages in optimized minimalist time frames...

Maybe my brain just got warped by all that AI/Lisp work I did for a
couple decades, but it feels to me like a bad selection of weapons for
the task at hand, most times I see it in PHP. [shrug]


There are different levels of applications that are 'spitting out HTML 
web pages'. If you're developing a system where each script is 
independent and simply makes use of shared code then OOP is almost 
certainly not worth it.


When you get to a system of the size I deal with (several thousand files 
with several hundred classes and a single entry point) it becomes a lot 
easier to deal with that in an OOP fashion.


As for your other posts about have a class that represents a single 
customer not being a good idea if you are going to be dealing with 
potentially large sets of customers, I would have to agree 
whole-heartedly. And I apologise if I read your post as an absolutely 
anti-OOP opinion when it was not.


I came from a C/C++ background and feel that I understand the good and 
the bad effects of using OOP very well. In a PHP environment you 
generally need to take more care with how you architect the system to 
take into account the build and tear-down that occurs with each request, 
but OOP can still be used to great effect in large PHP sites.


I do take issue with your 'free advice' when you say you should base 
your OOP code on your existing code. One of the things OOP does is 
allow/force you to think about the way you deal with data in your 
application from a different angle. That's definitely worth doing. In my 
experience developers get stuck in their habits far too easily and 
anything that causes you to re-evaluate the way you to things has to be 
worthwhile.


Anyways, some of that probably didn't make much sense, so I need to 
write some code now.


-Stut

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Stut

Ed Lazor wrote:


On Oct 12, 2006, at 10:18 AM, Richard Lynch wrote:

I can't architect a good OOP solution to a problem that hasn't been
fully defined, any more than one can architect a house without knowing
all the rooms that are needed...


Sorry to jump into the middle of the conversation, but I thought this 
was a pretty interesting comment.  It serves as one of those occasional 
reminders that I need to go back and study OOP structure design a bit 
more.  I know you're right about the importance of a fully defined 
problem, but it also seems that the reverse is true if you're really 
good with OOP.  In other words, it seems like any high quality solution 
starts by defining least common denominators.  You start with basic 
building blocks and expand from there; I'm always amazed when I see 
space stations or other complex structures built out of Legos, for 
example.  My problem is that I usually look at OOP and think it'll take 
too long, so I go the non-OOP route, solve the problem, and move on.  I 
can't help but think I'm missing out.  I do have libraries of code that 
I reuse, but I've always heard that I'd benefit a lot more from them if 
I OOPed them.  Dunno...  that's my two cents worth anyway hehe


Except that is the attitude that leads to painful OOP in PHP. PHP is not 
the same environment as C++. The environment (classes, objects, etc) 
needs to be created and destroyed with each request. As such you cannot 
start designing a solution unless you know how the data/entities are 
going to be used. OOP in PHP cannot start with basic building blocks, at 
least not if you want a system that performs reasonably well.


-Stut

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Richard Lynch
On Thu, October 12, 2006 1:03 pm, Ed Lazor wrote:
 On Oct 12, 2006, at 10:18 AM, Richard Lynch wrote:
 I can't architect a good OOP solution to a problem that hasn't been
 fully defined, any more than one can architect a house without
 knowing
 all the rooms that are needed...

 Sorry to jump into the middle of the conversation, but I thought this
 was a pretty interesting comment.  It serves as one of those
 occasional reminders that I need to go back and study OOP structure
 design a bit more.  I know you're right about the importance of a
 fully defined problem, but it also seems that the reverse is true if
 you're really good with OOP.  In other words, it seems like any high
 quality solution starts by defining least common denominators.  You
 start with basic building blocks and expand from there; I'm always
 amazed when I see space stations or other complex structures built
 out of Legos, for example.  My problem is that I usually look at OOP
 and think it'll take too long, so I go the non-OOP route, solve the
 problem, and move on.  I can't help but think I'm missing out.  I do
 have libraries of code that I reuse, but I've always heard that I'd
 benefit a lot more from them if I OOPed them.  Dunno...  that's my
 two cents worth anyway hehe

Rapid prototyping in OOP, if you're willing to chuck the prototyping
if it turns out to be the wrong OOP model is do-able.

Even building the basic blocks first is fine -- but you've got to have
the whole structure in your mind if you expect those blocks to fit in
well.

This is probably not really specific to OOP, but I think it tends to
be more obvious with OOP when you start trying to work around the
short-sighted architecture.  By which I only mean that in procedural
programming, the work-arounds feel less like work-arounds, at least at
first, as they are not so obviously work-arounds, and just look like
more functions.

To get back to the ORIGINAL point -- OOP is not about raw performance.

It's about maintainability, code re-use, encapsulation, etc.

You can get acceptable performance from OOP if you know what you are
doing -- If you don't, it's super easy for a beginner to write a total
performance hog following all the best practices in the world.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-12 16:29:09 -0500:
 On Thu, October 12, 2006 1:03 pm, Ed Lazor wrote:
  On Oct 12, 2006, at 10:18 AM, Richard Lynch wrote:
  I can't architect a good OOP solution to a problem that hasn't been
  fully defined, any more than one can architect a house without
  knowing
  all the rooms that are needed...
 
  Sorry to jump into the middle of the conversation, but I thought this
  was a pretty interesting comment.  It serves as one of those
  occasional reminders that I need to go back and study OOP structure
  design a bit more.  I know you're right about the importance of a
  fully defined problem, but it also seems that the reverse is true if
  you're really good with OOP.  In other words, it seems like any high
  quality solution starts by defining least common denominators.  You
  start with basic building blocks and expand from there; I'm always
  amazed when I see space stations or other complex structures built
  out of Legos, for example.  My problem is that I usually look at OOP
  and think it'll take too long, so I go the non-OOP route, solve the
  problem, and move on.  I can't help but think I'm missing out.  I do
  have libraries of code that I reuse, but I've always heard that I'd
  benefit a lot more from them if I OOPed them.  Dunno...  that's my
  two cents worth anyway hehe
 
 Rapid prototyping in OOP, if you're willing to chuck the prototyping
 if it turns out to be the wrong OOP model is do-able.
 
 Even building the basic blocks first is fine -- but you've got to have
 the whole structure in your mind if you expect those blocks to fit in
 well.

Erm, I stopped doing BDUFs when I had to throw out two
unimplementable designs and 2 x approx. 2000 LOC. The third attempt
grew test-first, with better results.
 
-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Ed Lazor

Comments / Questions below.

On Oct 12, 2006, at 12:15 PM, Stut wrote:

Except that is the attitude that leads to painful OOP in PHP. PHP  
is not the same environment as C++.
The environment (classes, objects, etc) needs to be created and  
destroyed with each request.


I definitely agree that PHP is not the same as C++.   I agree with  
the need for high efficiency and performance with low overhead.   
Actually, it's funny you mention that, because I've argued those same  
points with C/C++ coders new to PHP.


As such you cannot start designing a solution unless you know how  
the data/entities are going to be used.


Doesn't this mean that your design breaks when the behavior or use of  
the data/entities changes?


OOP in PHP cannot start with basic building blocks, at least not if  
you want a system that performs reasonably well.


Right.  That makes sense with PHP being an interpreted language.   
I've tried to offset this somewhat by compiling libraries and having  
them cached before pages that rely on these libraries load.


I'm trying to get a better idea of how you leverage the advantage of  
OOP in PHP.  Do you use it?  If so, how?  Do you use any OOP  
methodologies?  If so, which ones? For that matter, how many of your  
projects start with a detailed description of all data/entities and  
how they are going to be used?


Does your experience differ a lot from mine?  My customers rarely  
have a complete understanding of what they'll be doing.  They usually  
only have a general idea.  Part of my challenge is to help them  
define that idea, especially when it comes to defining the scope of  
the initial project.  Yes, scope creep is to be avoided or managed in  
projects, but customers are always finding new and creative ways to  
apply their ideas.  Things have to be flexible enough to support  
current needs and future needs.  You're saying that you cannot start  
designing a solution unless you know how the data/entities are going  
to be used.  I'm saying that you have to start somewhere and that  
code has to be extensible enough to meet growing demands.  I'm sure  
that you try to come up with flexible designs, but I'm wondering.   
What is your approach?


Also, isn't OOP supposed to be about separating data from programming  
logic?  If that's the case, isn't how you use that data irrelevant?   
That seems like one of the greatest promises of OOP, but maybe that's  
just the hype?


On Oct 12, 2006, at 2:29 PM, Richard Lynch wrote:

Rapid prototyping in OOP, if you're willing to chuck the prototyping
if it turns out to be the wrong OOP model is do-able.


Do you end up throwing away a lot of code?


Even building the basic blocks first is fine -- but you've got to have
the whole structure in your mind if you expect those blocks to fit in
well.


It sounds like you (Both Stut and Richard) have done a lot of this,  
so I'm sure you know what you're talking about.  Like I mentioned in  
my original post, I think I need to spend time learning better object  
modeling in order to take better advantage of OOP.  I still can't  
help but wonder.  How do you know if you have the full structure?   
Don't you end up going back and changing things a lot?



This is probably not really specific to OOP, but I think it tends to
be more obvious with OOP when you start trying to work around the
short-sighted architecture.  By which I only mean that in procedural
programming, the work-arounds feel less like work-arounds, at least at
first, as they are not so obviously work-arounds, and just look like
more functions.


I'm honestly not sure if I understand what you're saying here, but I  
do know that I've always tended more toward linear / procedural  
programming with a lot of functions.  I have used OOP, but in very  
limited capacity - mainly to avoid the system overhead.  I think I've  
also avoided it because I usually run into problems with defining  
data in objects - similar to the original issue of creating a  
customer object only to run into the problem of how to handle objects  
that represent a collection of customers.  Again, me needing to get a  
better understanding of data modeling in OOP.  It seems like you  
still end up having to learn data modeling the PHP way; people are  
probably critical of PHP because of this, but it seems like there's a  
middle ground and I'm curious where you guys have found that to be.   
Should I take this off the mailing list and talk with you about it in  
separate email?



To get back to the ORIGINAL point -- OOP is not about raw performance.

It's about maintainability, code re-use, encapsulation, etc.

You can get acceptable performance from OOP if you know what you are
doing -- If you don't, it's super easy for a beginner to write a total
performance hog following all the best practices in the world.


Definitely agree with you there.

-Ed

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Tony Marston

Richard Lynch [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Thu, October 12, 2006 3:11 am, Tony Marston wrote:
 I have to disagree as well. There is absolutely nothing wrong which
 the
 approach of creating one class for each table in the database. It
 cannot be
 wrong for the simple reason THAT IT WORKS!

 Only problem is that then you often end up making ONE INSTANCE for
 each *row* in a large result set, and then you are in BIG TROUBLE.

 IT DOES NOT WORK!

 You've *got* to have some kind of other class that handles more than a
 couple handsful of the data, for anything other than a trivial
 application.

I don't have, and never will have, one instance for each row. One instance 
can deal with any number of rows.

 And if it was trivial to start with OOP is rarely the right answer.

Something may start as trivial, but over time it can expand into something 
more than trivial, by which time you will lose out by not going down the OO 
route to begin with.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org 

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Stut
 will not shield you from the effects of having the 
system specification pulled from under your feet. However, it can be 
used to lessen the blow by anticipating what those future changes might 
be. That comes with experience and no methodology can get completely 
around it.


Also, isn't OOP supposed to be about separating data from programming 
logic?  If that's the case, isn't how you use that data irrelevant?  
That seems like one of the greatest promises of OOP, but maybe that's 
just the hype?


Yes and no. OOP actually brings data and the logic that works on it 
together, while keeping logic that doesn't work directly on the data 
awway. One of the core aims of the OOP methodology is to hide as much of 
the data behind an API that allows the implementation of that API to 
change without affecting how that API is used.


Having said that, it doesn't apply too much where PHP is concerned 
unless you are developing a set of classes for public consumption. What 
is more important is that by packaging data and logic together you end 
up with one place where it all happens, and you can choose how much of 
the internal workings are exposed to the rest of the system.


I'd also like to say that OOP itself is not hype. In the same way that 
podcasts themselves are not hype. It's what surrounds stuff that gives 
it the uneasy feeling that it's hype. Podcasting is the next stage of 
audio and video entertainment in the same way that colour TV was all 
those years ago. They hype exists because of the cruddy media-driven 
world we now live in where everything has to be hyped up if it's going 
to be popular, even if it's short-lived.


To relate that twoddle to PHP... OOP is a stable, mature methodology. 
However, OOP in PHP is fairly new (if you ignore PHP4's pitiful efforts) 
and there's still a lot of unease about this new kid on the block, along 
with a lot of hype around the idea that it will launch PHP into being a 
real programming language instead of just a web-based toy (can't 
recall where I read that, otherwise I'd provide a reference).


OOP is good, but it needs to be used where appropriate to the context. 
OOP should not be used for the sake of it, but it should also not be 
dismissed as a fad or hype.



On Oct 12, 2006, at 2:29 PM, Richard Lynch wrote:

Rapid prototyping in OOP, if you're willing to chuck the prototyping
if it turns out to be the wrong OOP model is do-able.


Do you end up throwing away a lot of code?


I can't speak for Richard, but hell yeah! I've probably thrown away more 
code than the amount I've written that is still in use. This is a 
fundamental hurdle that all developers need to get over. Not so 
prevalent now with the fresh developers arriving in the job market now, 
but in previous years there were too many who would refuse to throw away 
any code they had written for what I can only guess are sentimental reasons.


Write it once. Realise that it's ugly and wrong. Write it again. Realise 
that it's right but could be improved. Write it a third time and you 
should have a work of art.


If you're not willing to say that code I just wrote sucks, IMHO you're 
not a very good developer. In addition, if you're not willing to throw 
said code away because it too me hours, IMHO you're not a very good 
developer.


BTW, this is not related to OOP in the slightest. The same would go for 
any methodology.



Even building the basic blocks first is fine -- but you've got to have
the whole structure in your mind if you expect those blocks to fit in
well.


It sounds like you (Both Stut and Richard) have done a lot of this, so 
I'm sure you know what you're talking about.  Like I mentioned in my 
original post, I think I need to spend time learning better object 
modeling in order to take better advantage of OOP.  I still can't help 
but wonder.  How do you know if you have the full structure?  Don't you 
end up going back and changing things a lot?


Yes you do. And you should. If you don't then you've almost certainly 
done something wrong, probably not tested it enough.



This is probably not really specific to OOP, but I think it tends to
be more obvious with OOP when you start trying to work around the
short-sighted architecture.  By which I only mean that in procedural
programming, the work-arounds feel less like work-arounds, at least at
first, as they are not so obviously work-arounds, and just look like
more functions.


I'm honestly not sure if I understand what you're saying here, but I do 
know that I've always tended more toward linear / procedural programming 
with a lot of functions.  I have used OOP, but in very limited capacity 
- mainly to avoid the system overhead.  I think I've also avoided it 
because I usually run into problems with defining data in objects - 
similar to the original issue of creating a customer object only to run 
into the problem of how to handle objects that represent a collection of 
customers.  Again, me needing to get a better

Re: [PHP] OOP slow -- am I an idiot?

2006-10-12 Thread Ed Lazor
 to lessen the blow by anticipating what  
those future changes might be. That comes with experience and no  
methodology can get completely around it.


True, very very true hehe

Also, isn't OOP supposed to be about separating data from  
programming logic?  If that's the case, isn't how you use that  
data irrelevant?  That seems like one of the greatest promises of  
OOP, but maybe that's just the hype?


Yes and no. OOP actually brings data and the logic that works on it  
together, while keeping logic that doesn't work directly on the  
data awway. One of the core aims of the OOP methodology is to hide  
as much of the data behind an API that allows the implementation of  
that API to change without affecting how that API is used.


Ok... I'm with you so far...

Having said that, it doesn't apply too much where PHP is concerned  
unless you are developing a set of classes for public consumption.  
What is more important is that by packaging data and logic together  
you end up with one place where it all happens, and you can choose  
how much of the internal workings are exposed to the rest of the  
system.


The only difference here is that I'd probably aim for all classes to  
be good enough for public consumption, but I know that takes more  
time in development.


Podcasting is the next stage of audio and video entertainment in  
the same way that colour TV was all those years ago.


*cough* AskNinja.com RULES! hehe *cough*

To relate that twoddle to PHP... OOP is a stable, mature  
methodology. However, OOP in PHP is fairly new (if you ignore  
PHP4's pitiful efforts) and there's still a lot of unease about  
this new kid on the block, along with a lot of hype around the idea  
that it will launch PHP into being a real programming language  
instead of just a web-based toy (can't recall where I read that,  
otherwise I'd provide a reference).


Yea, that's why I was making sure to get PHP5.  It seems like  
providers are still lagging in implementing it tho?


I'd quite like an opinion from a Zend Engine developer here. As  
I've previously mentioned I primarily work with a fairly large OOP- 
based system but haven't noticed any great performance drain. While  
it's true that we use Zend Platform on both our development and  
production servers that's purely due to the sheer number of files  
involved in each request - something that would still be a problem  
if it were 100% procedural. And even without the platform enabled  
it's not particularly sluggish.


Are you at liberty to talk more about the OOP-based system you use?   
It is a PHP developer sweet or something?  I've seen a few, but I've  
never used them.



Are classes in PHP5 significantly slower than a functional solution?


I'm trying to find it, but I saw a test of this awhile back pointing  
out that classes introduce a lot of overhead... having to load a  
function into memory versus loading the class and then instantiating  
it, etc. before you can call anything...


I'm really curious if any other developers have feedback or comments  
on this, especially the OOP methodologies.


-Ed

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Chris de Vidal
--- Johan Martin [EMAIL PROTECTED] wrote:
 You should look into getting Professional PHP5 by Lecky-Thompson,  
 Eide-Goodman, Nowicki and Cove from WROX.
...
 The collection class in chapter 5 discusses a programming problem  
 just like yours.

I will look into that, thank you.

CD

Think you#39;re a good person?  Yeah, right!  ;-)
Prove it and get ten thousand dollars:
TenThousandDollarOffer.com

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Chris de Vidal
--- Larry Garfield [EMAIL PROTECTED] wrote:
 For your rudimentary example of object-relational mapping below, yes, 
 performance is going to be atrocious.  That's because you're not taking any 
 advantage of the features that using OOP gives you.

Well, I /thought/ I was taking advantage of black box-style hiding (not sure 
what it's called),
that is, making sure the only place I type (and modify) my SQL query is hidden 
inside the private
method of a class.


 Again, pull extra data if you can.  A somewhat larger result set is (usually) 
 better than multiple queries.  How much you want to front-load in your object 
 and how much you want to defer to later depends on your specific problem and 
 how frequently the data will be used.

OK that somewhat answers the question.


 5) If you need to grab 100 objects at once, but just need basic data out of 
 them, use a factory.  Vis, 

(code snipped)

I /think/ I understand the code.  But I'd need more than just basic data, so I 
probably will just
write a query.


 6) If you need to do a complex query with a couple of joins and such, then 
 don't waste your time or the computer's trying to shoe-horn it into SQL.  SQL 
 is not inherently OO to start with!  Just write your query and loop it and be 
 happy.  OOP is not the answer to all problems.  Sometimes it does just make 
 matters worse, no matter what Sun tries to tell you. :-)

LOL

Yeah, I was thinking of shoe-horning things into SQL for speed.


   I want my data to _only_ be accessed from the black box called an OOP
   class. 
 
 That will work and is achievable in about 30% of all situations.  For the 
 other 70%, you will have to just hunker down and *gasp* write SQL specific to 
 the task at hand at least some of the time.  How much of the time once again 
 depends on your situation and the problem you're trying to solve.

*gasp*

:-)


From what it seems like people are telling me, it's a good idea to boot OOP 
for large numbers of
objects where I need more than just a little information and just use an SQL 
query, as I
suspected.  At least, for PHP; I wonder what Java people do in this situation.

CD

Think you#39;re a good person?  Yeah, right!  ;-)
Prove it and get ten thousand dollars:
TenThousandDollarOffer.com

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Satyam


- Original Message - 
From: Chris de Vidal [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Wednesday, October 11, 2006 12:42 PM
Subject: Re: [PHP] OOP slow -- am I an idiot?



--- Johan Martin [EMAIL PROTECTED] wrote:

You should look into getting Professional PHP5 by Lecky-Thompson,
Eide-Goodman, Nowicki and Cove from WROX.

...

The collection class in chapter 5 discusses a programming problem
just like yours.


I will look into that, thank you.

CD



Regardless of whether you find the sugested book or not, do take note that a 
good place for functions as the one you require, as Johan sugestests, isin a 
class representing collections of the individual objects.  Thus, it is 
usually good to have a class representing individual objects (customer) and 
collections of the same (customers) or methods that provide information on 
groups or agregates of individual items.


Satyam

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Richard Lynch
On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote:
 I want to create a customer class which fetches its attributes from
 a MySQL database.

No, you don't. :-)

This is a classic example of the obvious OOP solution being wildly
inappropriate.

The sad thing is, there are a zillion applications out there doing it
just this way... :-(

Start thinking more in terms of what you want the whole application to
do, and build classes that do THAT, rather then starting with a single
customer and their info.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Stut

Richard Lynch wrote:

On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote:

I want to create a customer class which fetches its attributes from
a MySQL database.


No, you don't. :-)

This is a classic example of the obvious OOP solution being wildly
inappropriate.


Ok, so I now find myself in the unusual position of disagreeing with the 
Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP is 
all about.


You can encapsulate everything to do with a customer in an object. This 
ensures that you don't duplicate any code that works on customer data. 
You avoid duplication of code. As a result you can ensure data integrity 
because there is only one route to read and write it.


If this is not what you think OOP is all about, do please enlighten us 
as to the error of our ways.


-Stut

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



Re: [PHP] OOP slow -- am I an idiot?

2006-10-11 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-11 21:28:36 +0100:
 Richard Lynch wrote:
 On Tue, October 10, 2006 6:14 pm, Chris de Vidal wrote:
 I want to create a customer class which fetches its attributes from
 a MySQL database.
 
 No, you don't. :-)
 
 This is a classic example of the obvious OOP solution being wildly
 inappropriate.
 
 Ok, so I now find myself in the unusual position of disagreeing with the 
 Lynchmeister. Why is this wildly inappropriate? IMHO this is what OOP is 
 all about.

No, that's what trivial OOP examples applied to the letter where
a different approach is in order are. If you study the GoF book [GoF]
you'll see that the traditional claim objects model physical
entities from real world (and nothing else) is very simplistic
and terribly limiting.

[GoF] http://www.amazon.com/dp/0201633612/

If you paint yourself into this corner you'll find your code
grinding the database to death in the OO-relational impedance
mismatch. The OOP ideal of a single source of data is nice,
unfortunately the real world gets in the way.
 
 You can encapsulate everything to do with a customer in an object. This 
 ensures that you don't duplicate any code that works on customer data. 
 You avoid duplication of code. As a result you can ensure data integrity 
 because there is only one route to read and write it.
 
Who talks about duplicating business logic? You just need to have
more than one access point for the data.

 If this is not what you think OOP is all about, do please enlighten us 
 as to the error of our ways.

Imagine deleting many rows in a table one by one (pseudocode):

class Record
{
function __construct($id)
{
$this-id = $id;
}
function delete()
{
// DELETE FROM some_table WHERE id = $this-id
}
}
foreach ($records as $r) {
$r-delete();
}

instead of taking them with a single DELETE:

// assuming
// class Search;
// $searchBuilder = new SearchBuilder;
// $SearchBuilder-add(new LessThan('id', '501'));
// $search = $searchBuilder-result();

class RecordSet
{
function __construct(Search $search)
{
$this-search = $search;
}
function delete()
{
// DELETE FROM some_table WHERE $this-search-toSQL()
}
}

$recordset($search);
$recordset-delete();

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



  1   2   3   4   >