gpt4 book ai didi

php - 如何从 PHP 绑定(bind) Zorba 中的 XQuery 外部变量?

转载 作者:搜寻专家 更新时间:2023-10-31 22:14:56 25 4
gpt4 key购买 nike

可以Zorba XQuery 处理器 PHP API绑定(bind)到在 xquery 中声明为 external 的变量?

例如,xquery 中的这一行将绑定(bind)到名为 $foo 的外部变量;

declare variable $foo as xs:string external;

但我在 Zorba PHP API 文档中找不到显示如何执行绑定(bind)的 PHP 部分的示例,以便 PHP 变量 $foo 绑定(bind)到 xquery 变量 $foo.

可以吗?

最佳答案

您可以执行以下操作:

$query = $this->zorba->compileQuery("declare variable $i external; $i + 1");
$dctx = $this->zorba->getDynamicContext();

$param = $this->zorba->compileQuery(".");
$itemFactory = $this->zorba->getItemFactory();
$value = $itemFactory->createString("1");

$param->getDynamicContext()->setContextItem($value);

$dctx->setVariable("", "i", $param->iterator());

这有帮助吗?

关于php - 如何从 PHP 绑定(bind) Zorba 中的 XQuery 外部变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7646207/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com