Could someone help me to create a query using the Joomla API? I've been going round in circles.
What I have so far:
<?php
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Insert columns.
$columns = array('virtuemart_media_id', 'virtuemart_product_id');
// Insert values.
$values = array(); <---- How can i get the values
// Prepare the insert query.
$query
->insert($db->quoteName('#__virtuemart_product_medias'))
->columns($db->quoteName($columns))
->values(implode(',', $values));
// Set the query using our newly populated query object and execute it.
$db->setQuery($query);
$db->execute();
?/>
Now, the values I want are based on the following:
virtuemart_media_id
=#__virtuemart_medias.virtuemart_media_id
virtuemart_product_id
=#__virtuemart_products.virtuemart_product_id
- WHERE
#__virtuemart_products.product_sku
=#__virtuemart_medias.explode("-", strtoupper('file_url'), 2)
I want to insert the values into the #__virtuemart_product_medias
table.
$db-> explode()
. Try using justexplode()
. What exacting are you exploding though?