Forums

ERROR $db....how to translate Joomla function in Wordpress function

pierpul 22 Feb, 2017
Hi, I've installed Chronoforms in Joomla....all is ok.
Now, I've transpose my project in Wordpress....but there is a problem:
In a Custom code I've this string:

<?php
$db = \JFactory::getDBO();
$query = "
SELECT `cognomeosp`
FROM `wpds_cf_test3`
WHERE `cf_id` = '{$form->data['dropdown']}' ;
";
$db->setQuery($query);
$form->data['cognomeosp'] = $db->loadResult();

How I can translate "$db = \JFactory::getDBO();" for Wordpress?
And...is there another error in this string for wordpress use?

Please, help me.

Matteo
Max_admin 23 Feb, 2017
Hi Matteo,

Here is an example wordpress query:

<?php 
global $wpdb;
$metakey = "vatnumber";
$dbquery = $wpdb->prepare("SELECT meta_value FROM ".$wpdb->prefix."usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $metakey);
$vatnumber = $wpdb->get_var($dbquery);
?>


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger