本帖最后由 subendong 于 2011-01-10 13:10:56 编辑

解决方案 »

  1.   

    看看codeigniter框架http://codeigniter.org.cn/user_guide/database/index.html
      

  2.   

    dedecms的模板可以,其实你完全可以自己去实现个sql标签,
      

  3.   

    写这种烂代码都要*&*(&@(¥#8&%(@&#*
      

  4.   

    其实这个用框架或者原生的PHP应该都是可以实现的,你写好一个方法,进行调用就可以了
      

  5.   

    我擦,你用dreamwave拖动几下就成了。
      

  6.   


    //解析模板中的标签 $temp是模板中的字符串 解析后可以把返回值保存成模板缓存下次引用即可
    function temp_parse($temp) {
       $temp = preg_replace("/([\n\r]+)\t+/s","\\1",$temp);
       $temp = preg_replace("/\<\!\-\-\{(.+?)\}\-\-\>/s", "{\\1}",$temp);
       $temp = preg_replace("/\{\/get\}/","<?php } unset(\$DATA); ?>",$temp);
       $temp = preg_replace("/\{get\s+([^}]+)\}/e", "temp_getparse('\\1')", $temp);
       $temp = preg_replace("/\{([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff:]*\(([^{}]*)\))\}/","<?php echo \\1;?>",$temp);
       $temp = preg_replace("/\{\\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff:]*\(([^{}]*)\))\}/","<?php echo \\1;?>",$temp);
       $temp = preg_replace("/\{(\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\}/","<?php echo \\1;?>",$temp);   return $temp;
    }
    //解析 模板中SQL标签
    function temp_getparse($str)
    {
    preg_match_all("/([a-z]+)\=\"([^\"]+)\"/i", stripslashes($str), $matches, PREG_SET_ORDER);
    foreach($matches as $v)
    {
    $r[$v[1]] = $v[2];
    }
    extract($r);
    if(!isset($sql)) $sql = '';
    if(!isset($rows)) $rows = 0;
    if(!isset($return) || !preg_match("/^\w+$/i", $return)) $return = 'r';

    $str = substr($str, -1) == '/' ? "<?php \${$return} = get(\"$sql\", -1);?>" : "<?php \$DATA = get(\"$sql\", $rows);foreach(\$DATA AS \$n => \${$return}) { \$n++;?>"; return $str;
    }
    //模板中 自定义查询SQL 其中$msql是一个SQL的类 自己写或者网上找找 很多
    function bbsget($sql,$rows = 0)
    {
    if(!$sql) return false;
    global $msql;
    $rows = intval($rows);
    $limit = $rows>1 ? " LIMIT $rows" : '';
    $data = $rows<2 ? $msql->getone($sql) : $msql->select($sql.$limit);
    return $data;
    }
    上面是基本思路 和 详细代码了,我自己一个项目中用的,但不能直接使用,你需要整理一下。
    像你说这个例子,在模板中就这样写就行了<!--{get sql="select BlockName,ResourceMaterial,ResourceSpecification from View_Resource where ReMarketID=$M.ID" row='10'}-->  <tr>
      <td>{$r[BlockName]}</td>
      <td>{$r[ResourceMaterial]}</td>
      </tr>
    <!--{/get}-->
    这个算是比较基础的应用了,不过给你码代码真不容易,编辑器不好用,记得给分啊
      

  7.   

    自己写个标签。如ls某位兄弟说的 dede里面 
      

  8.   

    很多都支持吧!smarty {php}{/php}
    phpcms 忘了,但绝对可以