load from different database

sbischoff 13 Dec, 2012
Hi there,

I know that I can save data to a different database and not the joomla DBs.
But is there a change to load data from a different database?

Must I use a custom code and php and mysql-query to get the data out of the database into my form?

TIA and regards
GreyHead 14 Dec, 2012
Hi Steffen,

Neither of the Load actions have this built in (I don't know why, I guess that Max just didn't need it at the time he wrote them). You can do it with a few lines of code in a Custom Code action though. Please see this FAQ for the code.

sbischoff 16 Dec, 2012
Hi Bob,

thank you for the quick answer, but I guess you know me good enough, that you knew, that I will ask again!?😉

I've load my data from the database like this:
$db_server = 'sss';
$db_name = 'sss';
$db_user = 'xxx';
$db_passwort = 'xxx';

$db = @mysql_connect($db_server, $db_user, $db_passwort)
   or die ('Konnte keine Verbindung zur Datenbank herstellen');

mysql_select_db($db_name, $db);

mysql_query("SET NAMES 'utf8'");

$updatekey =  $form->data['updatekey'];

$SQL_String = 'SELECT DISTINCT * FROM ZerzuraAnmeldungStamm WHERE updatekey = "' . $updatekey . '"';

$result = mysql_query($SQL_String);

if (!$result) {
    $message  = 'Ungültige Abfrage: ' . mysql_error();
    $message .= 'Gesamte Abfrage: ' . $SQL_String;

while ($row = mysql_fetch_assoc($result)) {
    echo $row['Stamm'];
    echo $row['Ansprechpartner'];
    echo $row['Strasse'];
    echo $row['PLZ'];
    echo $row['Ort'];
    echo $row['Mail'];
    echo $row['Telefon'];
    echo $row['Mobil'];
    echo $row['Kommentar'];


Now I have my data, but how can I put them into the form fields?

Thanks and regards
GreyHead 17 Dec, 2012
Hi Steffen,

You'd add whatever data you want to use into the $form->data array e.g.
$form->data['db_data'] = $data;

Personally I'd do any pre-processing needed here too.

This topic is locked and no more replies can be posted.