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