Closed jbaron-mx closed 9 years ago
@jbaron30, I think you can make a workaround for this by creating a database view to show the db-link table instead of using it directly. Then just reference the database view on your model. But this approach may only be useful for fetching records and not for create/update/delete.
Thanks yajra, I appreciate your response. Yeah that approach should do the job, unfortunately this is a production server of my client and I don't have the permissions to create o modify any table or views on the database, so I'm restricted to fetch records in that way only.
If someone needs a workaround to this, I had figure out which function was concatenating the table name with the field name and you have to override it as follows:
I've added a function to the OracleEloquent class from this package to override the functionality of the Model class:
/**
* Get the table qualified key name.
*
* @return string
*/
public function getQualifiedKeyName()
{
$pos = strpos($this->getTable(), '@');
if ($pos === false) {
return $this->getTable().'.'.$this->getKeyName();
} else {
$table = substr($this->getTable(), 0, $pos);
$dblink = substr($this->getTable(), $pos);
return $table.'.'.$this->getKeyName().$dblink;
}
}
Now is working any find method for my Eloquent model. Also note that now I'm using this OracleEloquent class on my model instead of the regular Model class.
use yajra\Oci8\Eloquent\OracleEloquent as Model;
Thank you. I hope in some point of the future Laravel take care of that kind the situations with OCI8.
Glad you were able to sort this out. Will add your fix on OracleEloquent. Thanks!
Hello friends.
Hope someone could help me. I'm currently facing a problem if I set a table on my model that reference to a db-link.
This is my model:
It works well if I try to select data only.
But if I try to find some record by its id, it fails because Eloquent tries to concatenate the table name with the id field, which is wrong because the db-link is between them:
Returns:
That failing where clause it supposed to be like this:
Is there any way to fix this?. Greetings.