duanlan3598 2015-05-04 20:18
浏览 57

获取mysql查询以使用具有命名空间的类

I'm creating a XML file for SEPA Direct Debit.

I'm using https://github.com/dmitrirussu/php-sepa-xml-generator and have the example work ok BUT I don't seem to be able to use it INSIDE A MYSQL WHILE...

I have used composer to install throught composer.json.

EXAMPLE WORKING:

<?php
require 'vendor/autoload.php';

//When you start to generate a SEPA Xml File, need to choose PAIN
$directDebitTransaction = \SEPA\XMLGenerator::PAIN_008_001_02;// For Direct Debit transactions is By Defaut

$sepa = SEPA\Factory\XMLGeneratorFactory::createXmlGeneratorObject($directDebitTransaction)->addXmlMessage(
    SEPA\Factory\XMLGeneratorFactory::createXMLMessage()
        ->setMessageGroupHeader(
        SEPA\Factory\XMLGeneratorFactory::createXMLGroupHeader()
            ->setMessageIdentification(1)
            ->setInitiatingPartyName('Amazing SRL ???? ыаывпавпва '))
            ->addMessagePaymentInfo(
        SEPA\Factory\XMLGeneratorFactory::createXMLPaymentInfo()
            ->setPaymentInformationIdentification(6222)
            ->setSequenceType('RCUR')
            ->setCreditorAccountIBAN('MD24 AG00 0225 1000 1310 4168')
            ->setCreditorAccountBIC('AABAFI42')
            ->setCreditorName('Amazing SRL')
            ->setCreditorSchemeIdentification('FR07ZZZ519993')
            ->setRequestedCollectionDate('2013-08-06')
            ->setAggregatePerMandate(true) //Default Transaction aggregation option = true
/* TRANSACCION - 1 */
            ->addDirectDebitTransaction( //First transaction
            SEPA\Factory\XmlGeneratorFactory::createXMLDirectDebitTransaction()
                ->setInstructionIdentification(3)
                ->setEndToEndIdentification(3)
                ->setInstructedAmount(100.5)
                ->setDebtorName('Roy SRL')
                ->setDebitIBAN('FR14 2004 1010 0505 0001 3M02 606')
                ->setDebitBIC('AABAFI22') //Optional
                ->setMandateIdentification('SDD000000016PFX0713') //unique Identifier
                ->setDateOfSignature('2013-08-03')
                ->setCurrency('EUR')
                ->setDirectDebitInvoice(122)
           )
/* TRANSACCION - 2 */
// ...
/* TRANSACCION - 3 */
// ...
/* TRANSACCION - N */
// ...
    )
);

/* this is the part I need to use to REPLACE the transactions parts above */
$mysqli = new mysqli("localhost","root","","test");
if ($result = $mysqli->query("SELECT * FROM test"))
{
    while ($data = $result->fetch_object())
    {
        /*
        * here we get the data needed for the addDirectDebitTransaction()
        */
    }
}
$result->free();
$mysqli->close();

/* save XML */
$sepa->view()->save(realpath(__DIR__) .'/test.xml');

/* EOF */

As I said, this works but I dont undertand well the namespaces and I'm not able to do such a simple thing...

Help, please...

  • 写回答

2条回答 默认 最新

  • dongmeng9048 2015-05-04 20:29
    关注

    You don't work with XML, but SEPA. XML is only used indirectly as a serialization format.

    You call the methods of that specific PHP library that generates the SEPA message.

    That said, generate the payment information first and store it into a variable. Use the loop to add transactions, generate the message and append the payment information.

    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭