Thanks everyone. I am trying to use DirectPHP extension to allow me to put the php right in the article. I can access normal php now. I have written this, and as soon as I try to load my results, it all comes crashing down. Do you see something specific taht I am doing wrong, and how do I get the result back? I've tried ->query, ->execute, ->loadResults, etc. I have defined <my database>, <my ip>, <my pwd> etc in my actual file. I get a Eval error whenever I try to actually get the data back. My query is simple for testing, SELECT title from events; It will return 1 row with one title. Seems like the articles above are out of date (says so right at the top of the article, that is flagged out of date). Using most recent Joomla
<?php
$option = array(); //prevent problems
$option['[[drive]]'] = 'mysql'; // Database [[drive]] name
$option['host'] = '<my ip address>'; // Database host name
$option['user'] = '<my database>'; // User for database authentication
$option['password'] = '<my password>'; // Password for database authentication
$option['database'] = '<my database>; // Database name
$option['prefix'] = ''; // Database prefix (may be empty)
$db = JDatabase::getInstance( $option );
// Create a new query object.
$query = $db->getQuery(true);
$query->select('title');
$query->from('events');
// Reset the query using our newly populated query object.
try
{
$db->setQuery($query);
< ANYTHING HERE TO DO AN EXECUTE OR LOAD RESULTS, CRASHES with an EVAL error>
}
catch (RuntimeException $e)
{
throw new Exception($e->getMessage());
}
via Joomla! http://forum.joomla.org/viewtopic.php?t=861904&p=3229013#p3229013
<?php
$option = array(); //prevent problems
$option['[[drive]]'] = 'mysql'; // Database [[drive]] name
$option['host'] = '<my ip address>'; // Database host name
$option['user'] = '<my database>'; // User for database authentication
$option['password'] = '<my password>'; // Password for database authentication
$option['database'] = '<my database>; // Database name
$option['prefix'] = ''; // Database prefix (may be empty)
$db = JDatabase::getInstance( $option );
// Create a new query object.
$query = $db->getQuery(true);
$query->select('title');
$query->from('events');
// Reset the query using our newly populated query object.
try
{
$db->setQuery($query);
< ANYTHING HERE TO DO AN EXECUTE OR LOAD RESULTS, CRASHES with an EVAL error>
}
catch (RuntimeException $e)
{
throw new Exception($e->getMessage());
}
Statistics: Posted by tarapage — Wed Oct 15, 2014 8:13 pm
via Joomla! http://forum.joomla.org/viewtopic.php?t=861904&p=3229013#p3229013
No comments:
Post a Comment