DELETE from table with database name prefix in Editor PHP
DELETE from table with database name prefix in Editor PHP
Hello, I think there is a little inconsistency using database name prefix in Editor (1.6.3)
Suppose I have something like
$editor = Editor::inst( $db, 'db.table' )
and all fields referencing db.table.field
Then I'm not able to delete records from this table.
In Editor.php file there is a _remove_table
function with condition:
$this->_part( $field->dbField(), 'table' ) === $table && ...
The table
on the left side doesn't have a prefix while on the right side there is a db.table
variable.
I think that's why the DELETE query is never generated.
There should be probably something like:
$this->_part( $field->dbField(), 'db' ).'.'.$this->_part( $field->dbField(), 'table' ) === $table && ...
instead.
Answers
Why do you think you need "db.table"? The database name is already in the $db object.
Thanks for flagging this up. I haven't tried to replicate it here yet, but I agree that very much does sound like a bug.
If you are able to, then @tangerine's suggestion of dropping the db prefix would be a way to workaround this. Although if you are using it as an intradatabase connection, that wouldn't work.
Allan
Thanks for your answers.
I need to join tables from different databases, so I assume that using db prefix is the only way to do it...
Ah, ok. I didn't think of that as I've never needed to do it myself.
Yes - the db prefix is the way to do it. If it worked... I'll post back here once I've dug into it and applied a fix.
Thanks,
Allan
Hello allan,
just a reminder:
The bug in Editor.php (v 1.8.1) _remove_table function, row 1933 still persists.
Any chance for fix? :-)
Thanks, MK