phpdevshell team mailing list archive
-
phpdevshell team
-
Mailing list archive
-
Message #01129
Re: [Question #209172]: How can I interact with a remote database in my own plugins?
Question #209172 on PHPDevShell changed:
https://answers.launchpad.net/phpdevshell/+question/209172
Status: Needs information => Open
pystone gave more information on the question:
I think I'd better put these here. If anyone bump into the same problem, he/she can get the answer here.
Here is my own class extends from PHPDS_legacyConnector.
<?php
class PY_Connector extends PHPDS_legacyConnector
{
protected $dbHost = "pystone";
protected $dbName = "mysql";
protected $dbUsername = "root";
protected $dbPassword = "mypw";
//private $link;
private function applyConfig($db_config = '')
{
$db = $this->db;
// Retrieve all the database settings
$db_settings = PU_GetDBSettings($this->configuration, $db_config);
// For backwards compatibility, set the database class's parameters here as we don't know if anyone references
// db's properties somewhere else
$db->server = 'localhost';
$db->dbName = 'mysql';
$db->dbUsername = 'root';
$db->dbPassword = 'mypw';
// Set our own internal properties for faster access and better accessibility.
$this->dbDSN = $db_settings['dsn'];
$this->dbHost = $db_settings['host'];
$this->dbName = 'mysql';
$this->dbUsername = $db_settings['username'];
$this->dbPassword = $db_settings['password'];
$this->dbPersistent = $db_settings['persistent'];
$this->dbPrefix = $db_settings['prefix'];
$this->dbCharset = $db_settings['charset'];
echo 'haha';
}
}
If I use it by just extending the class in model.php from PY_Connector, like
class testsql_select extends PHPDS_query
{
protected $sql = "SELECT `password` FROM `user` WHERE `Host` = 'localhost';";
protected $singleValue = true;
protected $connector = 'PY_Connector';
}
I will get the error message, "Table 'phpdev.user' doesn't exist". It seems that all the settings do not work.
--
You received this question notification because you are a member of
PHPDevShell, which is an answer contact for PHPDevShell.