简体   繁体   English

如何将数据从用户modx数据库导出到表单?

[英]How to export data from user modx database to form?

I've table in modx database (orders), and i need to export data from that db to table at site. 我已经在modx数据库中创建了表(订单),并且我需要将数据从该数据库导出到站点中的表。 I pushing into db with following snipept 我跟随以下片段进入数据库

<?php
function agregarCargas( &$fields )
    {
        global $modx;
        // Init our array
        $dbTable = array();
                $dbTable['subject'] = $modx->db->escape($fields['subject']);
        $dbTable['fullname'] = $modx->db->escape($fields['fullname']);
        $dbTable['message']     = $modx->db->escape($fields['message']);
        // Run the db insert query
        $dbQuery = $modx->db->insert($dbTable, 'orders' );
        return true;
    }
?>

How can i export from DB? 如何从数据库导出? Snippet or? 片段还是? Thanks. 谢谢。

(Old thread, just for new folks trying to tackle this...) (旧线程,仅供尝试解决此问题的新手...)

Looking at the API you're using I'm guessing you are stuck with an old MODx version. 看一下您正在使用的API,我猜您仍然受制于旧的MODx版本。 (Evolution) (演化)

You should take a look at the API::DB docs for MODX Evolution 您应该看一下MODX Evolution的API :: DB文档

Something along the lines of the following would fill your HTML table: 以下内容将填充您的HTML表:

$res        = $modx->db->select("subject, fullname", 'orders');
$res_rows   = $modx->db->makeArray($res);
$rows       = "";
for($n=0;$n<count($res_rows);$n++){
    $rows  .= "<tr><td>".$res_rows['subject']."</td><td>".$res_rows['fullname']."</td></tr>\n";
}
return $rows;

(Of course you should use chunks instead of hardcoded HTML) (当然,您应该使用块而不是硬编码的HTML)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM