REST PHP数据库 - 不确定输出语法?

时间:2015-05-02 21:06:17

标签: php rest

我在一个安静的应用程序的网站上使用一个例子,我不确定我用哪些文本/变量代替我的数据库表。你能帮忙指出我应该在PHP代码中输入我的表名吗?

/**
 * Output the top level table listing.
 */
function database() {
    header('Content-Type: text/xml');
    echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
    echo '<database xmlns:xlink="http://www.w3.org/1999/xlink">'."\n";
    if (isset($this->PHPRestSQL->output['database'])) {
        foreach ($this->PHPRestSQL->output['database'] as $table) {
            echo "\t".'<table xlink:href="'.htmlspecialchars($table['xlink']).'">'.htmlspecialchars($table['value']).'</table>'."\n";
        }
    }
    echo '</database>';
}

/**
 * Output the rows within a table.
 */
function table() {
    header('Content-Type: text/xml');
    echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
    echo '<table xmlns:xlink="http://www.w3.org/1999/xlink">'."\n";
    if (isset($this->PHPRestSQL->output['table'])) {
        foreach ($this->PHPRestSQL->output['table'] as $row) {
            echo "\t".'<row xlink:href="'.htmlspecialchars($row['xlink']).'">'.htmlspecialchars($row['value']).'</row>'."\n";
        }
    }
    echo '</table>'; 
}

/**
 * Output the entry in a table row.
 */
function row() {
    header('Content-Type: text/xml');
    echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
    echo '<row xmlns:xlink="http://www.w3.org/1999/xlink">'."\n";
    if (isset($this->PHPRestSQL->output['row'])) {
        foreach ($this->PHPRestSQL->output['row'] as $field) {
            $fieldName = $field['field'];
            echo "\t".'<'.$fieldName;
            if (isset($field['xlink'])) {
                echo ' xlink:href="'.htmlspecialchars($field['xlink']).'"';
            }
            echo '>'.htmlspecialchars($field['value']).'</'.$fieldName.'>'."\n";
        }
    }
    echo '</row>';
}

0 个答案:

没有答案