Second Database Not configured Error in Laravel 5.3 - php

Friends, I am trying to develop a package in Laravel 5.3 release by using two databases within the host. The first, default, db connects to users table for all authentication and the second is specific to client. I may have many clients and each client will have his own set of tables within the host. It can be done in a single db but i am trying to do this for a specific reason.
The problem is i am getting an error that Dabatabase [18547383] not configured but it is configured and present in the system. The top of backtrace is reproduced below.
in DatabaseManager.php line 242
at DatabaseManager->getConfig('18547383') in DatabaseManager.php line 160
at DatabaseManager->makeConnection('18547383') in DatabaseManager.php line 68
at DatabaseManager->connection('18547383') in Model.php line 3351
at Model::resolveConnection('18547383') in Model.php line 3317
Upon probing a bit in the DatabaseManager.php, at line 240, I have tried to introduce an error to see the data present in the config array.
Strangely, all three named (defined in config) connections viz. mysql, mysql2 and pgsql have the same array values. In fact the pgsql configurations have not been populated in the config file yet they have the same values as that of the default. Hence, it is not finding the second db in the array and hence the error.
The question is, is it a bug in L5.3 ? how can I correctly populate the database connections so that it recognizes the second database.

Related

Laravel - Jobs can't connect to database

I am using some chained jobs in laravel, but suddenly they stopped working, in the log I can see that all the problems are connection problems, starting with
\vendor\laravel\framework\src\Illuminate\Database\Connection.php(638):
Illuminate\Database\Connection->runQueryCallback('select `section...', Array, Object(Closure))
In the console I do not receive any error, however, there is the job that is repeated and it tries again because the database rejected the connection, where can I check or set a correct connection of the jobs with the database?
The rest of my application works totally normal.
My queue.php file looks like this, but without line 84

magento sporadic db connection

So, I was getting the
"dbModel read resource does not implement Zend_Db_Adapter_Abstract"
error when I moved my install to a staging environment... and could not figure out what the problem was.
So, I checked the $connConfig object in app/code/core/Mage/Core/Model/Resource.php
What I discovered is that the object is created 119 times (?!) in the home page creation, and that 81 times it is false and 38 times it is the correct object.
Is this typical? Are there many times where the connection is set without db credentials for some reason? Or... is this my problem?
The answer is yes, there are many times when the db connection object is called with no data and it returns bool(false)... it's just fine.
...for those of you coming here trying to figure out:
dbModel read resource does not implement Zend_Db_Adapter_Abstract
My issue was a module (FishPig::Wordpress) which called a missing external database. The block which was being created was obvious in the debug trace. I just had to disable the createBlock-> call in a template file, or, eventually, install the external db :P

Transferring a system built in php(with cakephp) to the other server

I want to transfer a system to the other server with the deterioration of the server that a certain system works.
After transferring a program file and a database to a new server, an error occurs.
■Error contents
Warning (2): pg_query() [function.pg-query]:
Query failed: ERROR: An input sentence structure of model integer is invalid: "\x3234"
LINE 1: ...Aro0"."model" = 'User' AND "Aro0"."foreign_key" = '\x3234' ...
^ [CORE\cake\libs\model\datasources\dbo\dbo_postgres.php, line 148]
※Original Message(in japanese) : Query failed: ERROR: 型integerの入力構文が無効です: "\x37"
For environment
(former)
PHP: 5.2.13
CakePHP: 1.2.7
Apache: 2.2.15
Postgre: 8.4.4-1
(newly)
PHP: 5.5.15
CakePHP: 1.2.7
Apache: 2.4.10
Postgre: 9.2.9.1
I copied a program file from an old server after installation of PHP and Apache and PostgreSQL.
※I changed the connection server to the new server in database.php
※I describe php.ini, httpd.conf to become the setting same as an old server
Login screen (index.php) coming to be displayed,
and inputting ID and a password, and running login processing, the errors occurred.
The real error is ""foreign_key" = '\x3234'" part
that only numerical value guesses character string called"'\x3234'" right in foreign_key.
Only the number to 2 figures is really registered with the item equal to foreign_key even if I confirm a database.
Foreign_key which the login user has is "24",
but seems to be treated in one of login processing as "'\x3234'".
After doing it I tryed to login in other login users,
9 ⇒ '\x39'
7 ⇒ '\x37'
23 ⇒ '\x3233'
24 ⇒ '\x3234'
The left is foreign_key, and the right is really used by SQL.
A head has "\x3", and there seems to be "3" before the second column when there are two columns.
Is there any differents for settings of PHP/CAKEPHP/APACHE/POSTGRESQL ?

run an update on a linked MS Access table using php

I have Microsoft Access Database (mdb file) with a table in it (we'll call that table A) that is linked to another Microsoft Access Database (we'll call that table B). I need to be able to update table A using php (which will in turn update table B, since A is linked to B). Please note that the table I'm linking to has a primary key named "Intersection" and it is set to Indexed: Yes (No duplicates).
If I use a simple odbc_connect and odbc_exec to run the following query:
$con= odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$mdbFilename", $user, $password)
$res = odbc_exec($con, "UPDATE tableA SET myfield=NULL WHERE myfield=2439;");
However, when I try this on a database with a linked table, I get the following error:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC
Microsoft Access Driver] Operation must use an updateable query., SQL
state S1000 in SQLExecDirect in G:\web\libs\test.php on line 413
For some reason it seems that my database is not updateable even though it should be. It has a primary key defined and is a simple table (except for the fact that it's linked). Originally I was getting the following error:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC
Microsoft Access Driver] 'H:\test\Database\test.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you
are connected to the server on which the file resides., SQL state
S1009 in SQLExecDirect in G:\web\libs\test.php on line 413
But then I changed my linked table so instead of using drive letters to navigate to the linked table, I used the absolute \server\ path, which seemed to fix that problem, however not it is not able to be updated.
In case it helps, to create the Linked table, all I did was (Using MS Access 2010) I hit the "External Data" tab, then the "Access" (button), then I made sure to hit "Link to the source by creating a linked table" (option) and I selected the other database which contains the original table.
Is there some way to run an update on a linked access table using php?
Again, if you have a MS Access linked table that is linked to another table, and these tables have a primary key that is properly indexed. You CANNOT update the table using the following above PHP code (even though it works completely fine on an table which is not linked).
Please note, I have tested this with a fresh accdb database file as well, and if it is a linked table, it seems it will become read-only if you try to update the table using odbc_exec, however it does return data just fine, I just can't insert or update records.
Thank you.
[UPDATE]
Our server is running Windows Server 2003 with apache, and php. So I set up a Windows 7 machine with apache, and php, and it IS able to update a linked database without a problem, so I suspect my problem (since it's the only difference between the machines that could affect this), is that the Win2003 server is running odbc v3.5 whereas my win7 Machine is running odbc v6.1. I'm still looking into this further and will update this post if I find a solution to getting it working on our Windows Server 2003 machine.

Installing Akelos - Fatal Error

I'm completely new to the Akelos framework, but I am familiar with PHP. When I came across the framework I knew it was exactly what I was looking for but for the life of me I cannot get it to install properly.
Here are the steps that I went through and the details of my environment:
I am on a Mac Intel, using MAMP as my main environment
I have copied the Akelos files into my project folder.
When I navigate to localhost:8888 (as setup by mamp) I first get this error message:
(Warning) Cannot modify header
information - headers already sent by
(output started at
/Users/Salman/Work/_PERSONAL
PROJECTS/Web
Development/PHP_Development/SPM/public/index.php:50)
But when I refreshed the page that warning disappears and I successfully obtain the Akelos Getting Started page
I setup the database configuration, and proceed
I successfully set the language settings
First I get the following error:
(User Error) Could not create or alter
table akelos_migrations using the SQL
CREATE TABLE akelos_migrations ( id
INTEGER NOT NULL AUTO_INCREMENT, name
VARCHAR(255), version
INTEGER, updated_at
DATETIME, created_at
DATETIME,
PRIMARY KEY (id) )TYPE=InnoDB
When I refresh - everything "appears" to work fine and I am taken to to the "Welcome Aboard" page
When I try to run Script / Generate I get the following message:
Warning: mysql_connect(): [2002] No
such file or directory (trying to
connect via
unix:///var/mysql/mysql.sock) in
/Users/Salman/Work/_PERSONAL
PROJECTS/Web
Development/PHP_Development/SPM/vendor/adodb/drivers/adodb-mysql.inc.php
on line 353
Warning: mysql_connect(): No such file
or directory in
/Users/Salman/Work/_PERSONAL
PROJECTS/Web
Development/PHP_Development/SPM/vendor/adodb/drivers/adodb-mysql.inc.php
on line 353
Fatal error: Connection to the
database failed.
mysqlt://salman:******#localhost/socialPM_dev
in /Users/Salman/Work/_PERSONAL
PROJECTS/Web
Development/PHP_Development/SPM/lib/AkActiveRecord/AkDbAdapter.php
on line 66
This happens even if I try to manually create the akelos_migrations table using phpMyAdmin and SQL.
I would love to be able to use this framework - but I absolutely can't get past this!
Well the mysql socket file isnt usually in /var/mysql/mysql.sock on OS X. If you use the Mysql install from Mysql then its in /tmp/mysql.sock by default... The macports version is in /opt/local/var/run/mysql5/mysqld.sock by default. Im not sure where it is in MAMP because i dont use it, but my guess would be somewhere on the MAMP folder structure. You need to find out where it creates its socket and supply the path to it to your conifguration (i assume thats an option on the DB setup screen).

Categories