I have two applications inside one Codeigniter instance (Codeigniter 3.0). I need to share database config between applications. In each application I have config:
include_once 'application/shared/config/database.php';
But I have error on application start:
No database connection settings were found in the database config
file.
I decide to check variable
include_once 'application/shared/config/database.php';
var_dump(isset($db));
And what I see?
boolean true
boolean false
I'm trying to find difference between DB initializations, but not founded yet.
include instead of include_once is solution, but I think it is not correct.
What is the best solution?
Related
I'm new to Silex/PHP. I have the following snippet in my index.php.
$app->register(new \Silex\Provider\DoctrineServiceProvider(), array(
'db.options' => $dbConfig
));
dbConfig - is configurable (pdo_sqlite or pdo_mysql). Silex is run under lighttpd with php-fpm.
I have following questions:
Does Silex create "new" database connection for every request? If so, how does one optimize for performance so old/existing connection is used?
If new connection is not made, then how can one change the existing connection from one to other for the particular "app" instance when the database configuration changes? In this case, please assume that "app" is the one that process the configuration change and gets to know about it.
Thanks in advance.
I want that PHP/Drupal reads configuration settings which are stored in my CSCFG file and in my cloud service instance respectively.
How do I read configuration data (DB credentials) in a PHP web role in azure? I need them to access my database.
I have my DB credentials in two places
my azure account
(possibly) in my cscfg file
In my PHP script I want to get this data, so that my CSPKG files don't need to contain credentials. Example:
$db_host = azure_getconfig("DbHost");
$db_user = azure_getconfig("DbUser");
$db_password = azure_getconfig("DbPassword");
Is there a standard way how to do this?
About php_azure.dll: The approach that is usually described did not work for me. The suggested php extension php_azure.dll seems to be abandonded as it is marked as obsolete. I tried to load the extensions in all it's flavors but didn't succeed ("Unable to load dynamic library 'D:\Program Files (x86)\PHP\v5.3\ext\php_azure.dll' - The specified module could not be found.", even though the file exists for sure at the right path.).
So I assume, I shouldn't use php_azure.dll anyway.
There is a similar but unanswered question here:
How can I access ConfigurationSettings using a PHP Cloud Service on Windows Azure?
Does anyone know if mysqldump-php can work with shared hosting? I can get it to work on my local computer (I can get mysqldump to work locally also) but I need a method to backup a database that's hosted with a popular webhosting company. The only method that they offer to their customers is to sign onto phpMyAdmin and download your .sql manually. daily. yourself. no automation allowed. I'm a newbie and I'm going nuts trying to find a solution.
mysqldump-php called for
namespace Ifsnop\Mysqldump;
use Exception;
use PDO;
use PDOException;
It didn't mention needing command line access or SUPER privilege(s).
Am I using incorrect settings?
Here's the link to the code that I'm using on Github.
https://github.com/ifsnop/mysqldump-php#dump-settings
Any help would be so appreciated!
I've had a look in the code of ifsnop, and it uses SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ before starting the transaction. Global settings are only allowed with the SUPER-privilege (which you don't have on a shared environment, with a good reason ;) ).
You can either:
If you have only MyISAM-tables, there is no need for a transaction, so it can be turned off in the config.
$dumpConfig = array(
'single-transaction' => false
);
$md = new Mysqldump($db, $user, $pass, $host, 'mysql', $dumpConfig);
or; Change that word GLOBAL into SESSION (thus modifying the downloaded code).
I moved the installation to a different server. I updated the configfile in the var/ directory and the banners are served, but the admin interface is not working.
i get the error:
A fatal error occurred OpenX can't connect to the database. Because of
this it isn't possible to use the administrator interface
i cleaned the cache directory in var but then i get
PHP Fatal error: Call to undefined method MDB2_Error::quoteIdentifier() in /[path]/opx/lib/OA/Upgrade/VersionController.php on line 50
I dont know which version this is, but it looks like its at least 2 years old.
Is there any special cache in place im not aware of?
Any help on this would be much appreciated.
Mental note,.. if you have the db on a different server then openx it does not matter if you set the host to the ip of the db server and the port.. as long if you not set protocol=protocol !!!
this is by far the most stupidest thing i have ever seen, there is no need for a protocol config, as php always uses the socket if you set "localhost".
It's not easy to tell exactly what's wrong here, but one can make a good guess:
As we can see from the error message, there is an object in your code that doesn't implement the method quoteIdentifier().
There are mainly two possible reasons for this: Either we're calling an older or newer version of the same Class instance which doesn't implement the method. Maybe because it's deprecated or who knows. Or the object simply isn't of the expected type.
Lo and behold, if we look for an MDB2 related class that DOES implement this method, it's the class MDB2. Not MDB2_Error! So now we know the reason for the error, it's time to speculate about the root cause.
Connecting to a database with MDB2 works roughly like this:
$mdb2 =& MDB2::connect('pgsql://usr:pw#localhost/dbnam');
if (PEAR::isError($mdb2)) {
die($mdb2->getMessage());
}
There it is. We can see that $mdb2 can actually be of type MDB2_Error, in case connecting goes wrong for some reason. So that is the cause: Your code cannot connect to the DB for some reason. So the next obvious step should be checking if your db user has the correct rights and is using the correct password. I am 100% sure your admin backend doesn't use the right credentials.
I really don't know what causes this error.
CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]:
General error: 1 table 'YiiSession' already exists. The SQL statement executed was:
CREATE TABLE 'YiiSession' (
"id" CHAR(32) PRIMARY KEY,
"expire" integer,
"data" BLOB
)
Is it in the server or in yii..
but i guess it is in the yii part.
but what configurations did i miss?
i'm not really familiar with yii because im new to it.
any help please?
Thanks in advance
UPDATE: I check YiiSession in my database but it is not in there...
Delete the runtime folder.
Because runtime folder is used by the system for various tasks: session, logging etc.
It is also in the runtime folder that YiiSession table is created
In case anyone is still referencing this - the more complete answer is that Yii uses a SQLite3 database by default if you don't specify a connection string in your (CDbHttpSession) session config. This SQLite db is created in the runtime folder. (Which is why deleting the contents of the runtime folder works - you actually only need to delete the session-x.x.xx.db file.) If you want to use the same database you are using for your main connection, add:
'connectionID'=>'db',
to your session config. It's also recommended for production use you set autoCreateSessionTable to false, which will also prevent the error - you just need to make sure you deploy the SQLite db or set up the proper table in your main db. see here
By default, it will use an SQLite3 database named 'session-YiiVersion.db' under the application runtime directory. You can also specify connectionID so that it makes use of a DB application component to access database.