I want to create this address with php!

$a = new dbclass();


$a->delete(); //<<-- example!

$a->insert(); //<<-- example!

$a->update(); //<<-- example!


Please help me how to create class with this feature.

thanks a lot.

Thanks for helping!


I cannot create function for any tables and any fields of that!

I want to create a function when I send 'tablesname' or 'fieldsname' that can process them!

Are you understand?

It shows you how to create a function. It is up to you to define it's capabilities.

What is it you want to happen when you send a table name ?

pass table name, fields as parameters to function declaration,
and write db query in your function definition which is in class.
try coding ...

For example : I want to delete a row when field1 equal 5:
In this:

$row = new db();

I say again!
I cannot create function for any tables and any fields!

thanks a lot!

The way you want it is a bit weird, but it should be possible to write classes that work in this way. However, it is a bit too extensive to start writing code for you.

I written this!
But this is not professional and very simple!
This is limited!


class db
    private $condition;
    function __call($table,$argv)
        $this->condition = end($argv);
        $connection = mysql_connect('localhost','root','136');
        foreach($argv as $value)
            $fields .= $value . ",";
        $fields = substr($fields,0,strlen($fields)-1);
        $query = mysql_query("SELECT ". $fields ." FROM ". $table ." WHERE ".$this->condition);
        $row = mysql_fetch_array($query,MYSQL_ASSOC);
        return ($row);

$obj = new db();
// $row = $obj->table_name('field1' , 'field2' ,'field3'..... , 'condition'); <<-- you can write any tables!
$row = $obj->pages('topic','text','id=21');
echo "Topic: ".$row['topic']."<br>";
echo "Text: ".$row['text']."<br>";


Topic: test
Text: this is new

This is very simple!

Help please!

how to create this ?

$obj -> database -> table ('fields','conditions') -> database2 -> table2 ('fields','conditions');

Means how to send that to class?

thanks again

This is very hard to create (let alone debug), you'd need every function to return an object. In my opinion you may want to rethink how you want to do things.

How did you get to wanting that syntax ? It looks like jQuery. Or are you perhaps looking for something like this: http://phplinq.codeplex.com/

I wrote that!

Reading book.
Surfing in the Internet.

I know you wrote that. All I'd like to know is *WHY* you want something like this:

$obj -> database -> table ('fields','conditions') -> database2 -> table2 ('fields','conditions');

I want to access to database with less code!

Okay. I understand that. Trying to create such structure, involves writing a lot of code to get that working. So in the end you'll be writing much more code altogether. Why not use mysqli or pdo ?

mysqli,PDO is very good!
I see for the first!


Pear? Pear is good?

Yes, PEAR contains a lot of useful packages, for example MDB2 for data access.

I have a site!
I installed pear from cpanel!
How to use pear after the installing?