rene.brodmuehler@gmail.com
Member
Dear All
in the examples how to connect to a database I always find this for the beginning:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->insert('tablename')->set('field = ' . $db->quote('bar'))
->set('field2 = ' . $db->quote('{tablename___elementname}'));
$db->setQuery($query);
$db->execute();
I am not familiar with this kind of semantic. I guess I am more the procedural kind of guy and prefer this style:
$db = mysqli_connect($host,$user,$password,$database)
or die ("Abfrage konnte nicht durchgeführt werden 1 <br>\n");
$query = "SELECT SUM(e_netto) AS s_netto, SUM(e_netto)+1000 AS s_brutto FROM jahresrechnung_18_repeat WHERE parent_id = " . $myid;
$result = mysqli_query($db,$query);
Two questions please:
(1)
How can I translate
$db = JFactory::getDbo();
$query = $db->getQuery(true);
into my style
(2)
How can I extract the username, host, password and database from the $db variable.
I really appreciate your help.
Best regards
René
in the examples how to connect to a database I always find this for the beginning:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->insert('tablename')->set('field = ' . $db->quote('bar'))
->set('field2 = ' . $db->quote('{tablename___elementname}'));
$db->setQuery($query);
$db->execute();
I am not familiar with this kind of semantic. I guess I am more the procedural kind of guy and prefer this style:
$db = mysqli_connect($host,$user,$password,$database)
or die ("Abfrage konnte nicht durchgeführt werden 1 <br>\n");
$query = "SELECT SUM(e_netto) AS s_netto, SUM(e_netto)+1000 AS s_brutto FROM jahresrechnung_18_repeat WHERE parent_id = " . $myid;
$result = mysqli_query($db,$query);
Two questions please:
(1)
How can I translate
$db = JFactory::getDbo();
$query = $db->getQuery(true);
into my style
(2)
How can I extract the username, host, password and database from the $db variable.
I really appreciate your help.
Best regards
René