Datables Editor PHP Backend - LeftJoin and Edit
Datables Editor PHP Backend - LeftJoin and Edit
Hi, I am using a Oracle database with a lot of Schema, hence I have always to provide the SCHEMA.TABLE_NAME.
So far so good, this works until you do a Join. In such a case PHP Backend tries to find out the right tables to do insert/update/delete and here there is the code:
$this->_part( $fieldName, 'table' ) === $tableMatch
Here there is a comparission between SCHEMA.TABLE_NAME and TABLE_NAME. This obviously is never matching. The $count remains empty, the editor is doing nothing.
The (quick and dirty) fix seems working. I check, if there is a Dot and I remove SCHEMA.
private function _alias ( $name, $type='alias' )
{
if ( stripos( $name, ' as ' ) !== false ) {
$a = preg_split( '/ as /i', $name );
return $type === 'alias' ?
$a[1] :
$this->_removeSchema($a[0]);
}
if ( stripos( $name, ' ' ) !== false ) {
$a = preg_split( '/ /i', $name );
return $type === 'alias' ?
$a[1] :
$this->_removeSchema($a[0]);
}
return $this->_removeSchema($name);
}
// added by HaPi
private function _removeSchema($tableName) {
if (strpos( $tableName, '.' ) === false) return $tableName;
else return substr($tableName, strpos($tableName,'.')+1);
}
I just added the function _removeSchema() and used it in the 3 places above. This fixed the problem for insert, update, edit and delete.
This discussion has been closed.
Answers
Thanks for sending this in. I'll look into getting that integrated in and its implications.
Allan