Closed raice closed 4 years ago
@raice is this still relevant?
Is the issue fixed? I still can't generate model docblock by using multiple DB connection.
I'm using a project where some models use a different $connection
and it works correctly.
Please share more details:
I'm using a project where some models use a different
$connection
and it works correctly.Please share more details:
- code of the model
- database configuration
app/Models/CMCommunity.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class CMCommunity extends Model
{
protected $guarded = ['updated_at'];
protected $primaryKey = 'COMMUNITYID';
protected $connection = 'mysql_dev';
protected $table = 'osusr_mlv_community';
public $timestamps = false;
}
.env
DB_PROD_READ_HOST=localhost
DB_DEV_USERNAME=root
DB_DEV_PASSWORD=
DB_DEV_DATABASE=cm-external
config/database.php
'mysql_dev' => [
'sticky' => true,
'driver' => 'mysql',
'host' => env('DB_PROD_READ_HOST'),
'port' => '3306',
'database' => env('DB_DEV_DATABASE', ''),
'username' => env('DB_DEV_USERNAME', 'root'),
'password' => env('DB_DEV_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => false,
'engine' => null,
'options' => [
PDO::ATTR_EMULATE_PREPARES => true,
],
],
Not sure if any of these settings it. Try playing around, disabling sticky or remove options etc.
Pretty sure it's a local problem, are you sure it works on your dev machine? You env var containing "prod" sounds .. dangerous.
See here how the connection is resolved, in the end it uses exactly the property you give it:
Not sure if any of these settings it. Try playing around, disabling sticky or remove options etc.
Pretty sure it's a local problem, are you sure it works on your dev machine? You env var containing "prod" sounds .. dangerous.
See here how the connection is resolved, in the end it uses exactly the property you give it:
- https://github.com/barryvdh/laravel-ide-helper/blob/e8044dc9201cd7a237ce96f278cc303cc441600b/src/Console/ModelsCommand.php#L374
- https://github.com/laravel/framework/blob/9c539ca508107777840439380a76f74767e57bf4/src/Illuminate/Database/Eloquent/Model.php#L1308
- https://github.com/laravel/framework/blob/9c539ca508107777840439380a76f74767e57bf4/src/Illuminate/Database/Eloquent/Model.php#L1320
Yeah. prod
sounds dangerous. I have used it because the external database contains a huge amount of data and it is used in various subprojects. In my local development machine, I have some chunk of demo data from it. I know this is not an issue of a name but just let you know as you are curious about that. :smile:
Yes, It works in my development machine. I regularly use the database as most of the project page needs to load data from cm-external
database.
Yes, It works in my development machine
I then fail to understand what this issue is about?
Yes, It works in my development machine
I then fail to understand what this issue is about?
I am also thinking what is going on actually. I will try with a complete new project with multiple database connection and try to find out the issue.
I'm to close this issue in good faith:
Feel free to continue here or open a new issue once you've more details to share, thank you!
Using Lavarel Ide helper for a long time now. So thank you for that, really helpful tool!
Now I have a small project with 2 databases that need to be synchronized. When I generate models It only shows: /**
I defined connection (protected $connection) and the table name (protected $table). Checked the connection, but it can get data from the database.