我正在继续我的插件开发传奇.. 所以我已经纠正了我在previuos代码中犯下的所有错误 - > Use of joomla methods stops file to work in plugin
现在我认为我做得很好,但db查询不起作用。我不知道这里有什么问题,db查询对我来说很好看
<?php
// Set flag that this is a parent file
define('_JEXEC', 1);
// No direct access.
defined('_JEXEC') or die;
define( 'DS', DIRECTORY_SEPARATOR );
define('JPATH_BASE', dirname(__FILE__).DS.'..'.DS.'..'.DS.'..'.DS.'..' );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
jimport( 'joomla.database.database' );
$db = JFactory::getDbo();
if(JRequest::getInt('id'))
{
$id = JRequest::getInt('id');
$name = JRequest::getVar('name');
$query = "update #__messages set $name=$name+1 where id='$id'";
$db->setQuery( $query );
$db->query( $query ) or die('blogai');
?>
<div style="margin-bottom:10px">
<b>Ratings for this blog</b> ( <?php echo $total; ?> total)
</div>
<table width="700px">
<tr>
<td width="30px"></td>
<td width="60px"><?php echo $up_value; ?></td>
<td width="600px"><div id="greebar" style="width:<?php echo $up_per; ?>%"></div></td>
</tr>
<tr>
<td width="30px"></td>
<td width="60px"><?php echo $down_value; ?></td>
<td width="600px"><div id="redbar" style="width:<?php echo $down_per; ?>%"></div></td>
</tr>
</table>
<?php
}
答案 0 :(得分:0)
试试这个..为我工作
define( '_JEXEC', 1 );
chdir("../../");
getcwd();
define('JPATH_BASE', getcwd() );
define( 'DS', DIRECTORY_SEPARATOR );
require_once (JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
global $mainframe;
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
$db = JFactory::getDBO();