用户可以键入名称,系统应与文本匹配,即使用户输入或数据库字段包含重音(UTF-8)字符也是如此.这是使用该pg_trgm模块.
代码类似于以下内容:
SELECT
t.label
FROM
the_table t
WHERE
label % 'fil'
ORDER BY
similarity( t.label, 'fil' ) DESC
Run Code Online (Sandbox Code Playgroud)
当用户键入时fil,查询匹配filbert但不匹配filé powder.(因为重音字符?)
我试图实现一个unaccent函数并将查询重写为:
SELECT
t.label
FROM
the_table t
WHERE
unaccent( label ) % unaccent( 'fil' )
ORDER BY
similarity( unaccent( t.label ), unaccent( 'fil' ) ) DESC
Run Code Online (Sandbox Code Playgroud)
这只返回filbert.
建议:
CREATE EXTENSION pg_trgm;
CREATE EXTENSION unaccent;
CREATE OR REPLACE FUNCTION unaccent_text(text)
RETURNS text AS
$BODY$
SELECT unaccent($1); …Run Code Online (Sandbox Code Playgroud) 我正在阅读一篇标题为“ JSF 2 GETs Bookmarkable URLs ”的文章。
文章中有这样一段话:
视图参数简介
API 文档描述了视图参数,由 javax.faces.component.UIViewParameter 组件类表示,作为请求参数和模型属性之间的声明性绑定。与模型属性的绑定使用 EL 值表达式(例如,#{blog.entryId})来表达。如果省略表达式,则请求参数将绑定到具有相同名称的请求范围变量。
有人可以提供请求范围变量的示例吗?
我想简单地将一个值从子报告返回到主报告,但总是null在执行报告时显示。使用 iReport 5.1.0。
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report4" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ce028d85-f7e8-4abd-ad6b-e3b2ba04d14e">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\Users\\DellXFR\\"]]></defaultValueExpression>
</parameter>
<variable name="z" class="java.lang.Integer" calculation="System">
<variableExpression><![CDATA[8]]></variableExpression>
</variable>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<detail>
<band height="125" splitType="Stretch">
<subreport>
<reportElement uuid="0c501730-d98a-4982-9953-2939f127ad9e" x="40" y="10" width="200" height="100"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<returnValue subreportVariable="x" toVariable="z"/>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "report4_subreport1.jasper"]]></subreportExpression>
</subreport>
<textField evaluationTime="Band">
<reportElement uuid="9020a8d9-5799-4907-b8a3-704f41ffdcc0" x="399" y="73" width="100" …Run Code Online (Sandbox Code Playgroud) 在Pavel的页面上有以下功能:
CREATE OR REPLACE FUNCTION makedate(year int, dayofyear int)
RETURNS date AS $$
SELECT (date '0001-01-01' + ($1 - 1) * interval '1 year' + ($2 - 1) * interval '1 day'):: date
$$ LANGUAGE sql;
Run Code Online (Sandbox Code Playgroud)
我有以下代码:
makedate(y.year,1)
Run Code Online (Sandbox Code Playgroud)
PostgreSQL在给定年份的1月1日创建日期的最快方法是什么?
帕维尔的功能会让我相信它是:
date '0001-01-01' + y.year * interval '1 year' + interval '1 day';
Run Code Online (Sandbox Code Playgroud)
我的想法更像是:
to_date( y.year||'-1-1', 'YYYY-MM-DD');
Run Code Online (Sandbox Code Playgroud)
我正在寻找使用PostgreSQL 8.4的最快方式.(使用日期函数的查询可以选择100,000到100万条记录,因此需要速度.)
谢谢!
我希望有人可以帮助我,我需要反转文件中每一行的内容.所以基本上这个:101.228.168.192到192.168.228.101是否有一个命令我可以在bash脚本中使用,甚至只需要完成工作所需的逻辑.谢谢
如果我使用33到127之间的任何ASCII字符,则该codePointAt方法将给出正确的十进制值,例如:
String s1 = new String("#");
int val = s1.codePointAt(0);
Run Code Online (Sandbox Code Playgroud)
这将返回35,这是正确的值。
但是,如果我尝试使用从128到255的ASCII字符(扩展的ASCII / ISO-8859-1),则此方法给出了错误的值,例如:
String s1 = new String("ƒ") // Latin small letter f with hook
int val = s1.codePointAt(0);
Run Code Online (Sandbox Code Playgroud)
根据该参考表,这应该返回159 ,但是返回409,为什么呢?
我有一个文件
workers/activity/bulk_action.php,包含一个文件
include('../../classes/aclass.php');
Run Code Online (Sandbox Code Playgroud)
在aclass.php里面它做:
include ('../tcpdf/config/lang/eng.php');
Run Code Online (Sandbox Code Playgroud)
似乎第二个文件中的include使用的是第一个文件工作目录而不是相对于它自身,导致错误.这是如何运作的?
我有一个 XML,其中有一个带有标题、价格、作者、附加价格、艺术家、国家等属性的书籍列表。 XML 如下所示。
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<additionalprice>12.90</additionalprice>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<additionalprice>10.90</additionalprice>
<year>1988</year>
</cd>
Run Code Online (Sandbox Code Playgroud)
等等
我想编写一个应用于 XML 的 XSLT 3.0 来获取 HTML。我想使用累加器来获取目录中的书籍总数。尽管有更好的方法,但我只是想使用累加器进行练习,并在包含标题、作者和总价的书籍的表格末尾打印总数。对于填写标题和作者,我使用了 for-each。总价=价格+附加价格。我想使用 iterate 来归档总价。任何人都可以帮我解决这个问题。我不完整的样式表如下所示:
<?xml version="3.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="2">
<tr bgcolor="#9acd32">
<th style="text-align:left">Title</th>
<th style="text-align:left">Artist</th>
<th style="text-align:left">Total Price</th>
</tr>
<xsl:accumulator name="total" as="xs:integer" initial-value="0" streamable="no">
<xsl:accumulator-rule match="title" select="$value+1"/>
</xsl:accumulator>
<xsl:for-each select="catalog/cd">
<tr> …Run Code Online (Sandbox Code Playgroud)