PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB_Table » Bug #2906

$this->table attribute acces

Details

Request #2906$this->table attribute acces
Submitted2004-12-06 10:38 UTC
Frommquinton at gmail dot com
Assignedpmjones
StatusClosed
PackageDB_Table
PHP VersionIrrelevant
OSirrelevant
Roadmaps(Not assigned)

Comments

[2004-12-06 10:38 UTC] mquinton at gmail dot com

Description:
------------
hello,

I'm using Db_Table package for my own CMS. I have made a
subclasse for my local usage. I need to prefix table names.
So my subclass is like this :

class MyClass extends Db_Table{

var $prefix;

function table(){
return $this->prefix . $this->table;
}
}

but standard db_Table code is not usable directly. I need
to rewrite many methods ( insert, update, delete ...) or
modidify original source file like this :

class Db_Table {

var $table;

function insert($data)
{
...

# return $this->db->autoExecute($this->table, $data,
# MQ
return $this->db->autoExecute($this->table(), $data,
DB_AUTOQUERY_INSERT);
}

function table(){
return $this->table;
}
}

in that case, $table attribute access is overridable by subclasses.

could you take this in to account for next release ?

Reproduce code:
---------------
not a bug ...

[2004-12-20 20:32 UTC] mquinton at gmail dot com

here is an answer.

1 - the standard object form should be a call to a method, not directly to attribute,

2 - Yes, you have a good ideas, I did not thought about that, I can change constructor and manage a full table name. including prefix.

but some times, I need to know about prefix, and some times unprefixed values. I have some class using a special join statement without prefix like this :

$sql = array (
...
'insert' => array(
'join' => 'key:table:foreign_key(fields)'
)
...
);

in this statement, table should not be prefixed. This can be checked. So yes, I think, I will be able to go around in my class constructor.

But, really, I think your reply is not really very nice.

[2004-12-27 11:07 UTC] mquinton at gmail dot com

hello, I've done some checkings and now I can tell you,
I can use you DbTable class as is without need to change
any thing. I've rewriten buildSQL() method because this was
a need. And with this new method there is a work-around for
what I was asking to you.

thanks for your time.