我希望实现与...相同
window.open('lalala.php', 'lalala', '...');
Run Code Online (Sandbox Code Playgroud)
但我想发送HTTP POST请求而不是HTTP GET请求.因此,我使用以下内容:
$('<form/>').attr('action', 'lalala.php')
.attr('target', 'lalala') // w3schools.org says this is deprecated
.attr('method', 'post')
.append(hiddenParam('param1', param1))
.append(hiddenParam('param2', param2))
.submit().remove();
// hiddenParam is a function I created that returns an input tag
// the type attribute set to hidden,
// the id attribute set to the first parameter,
// and the value attribute set to the second parameter
Run Code Online (Sandbox Code Playgroud)
但是,该target属性已弃用.有没有办法通过非弃用手段实现我想要做的事情?
是否可以在SQL查询的子句中比较元组(thanks,a_horse_with_no_name)WHERE?那样,我可以转换这个:
/* This is actually a sub-sub-sub-query in the middle *
* of an incredibly complex stored procedure. */
SELECT ISNULL(SUM(DT.DetailField), 0)
FROM DetailTable DT
WHERE DT.ForeignKey = ...
AND EXISTS (/* I know this sub-sub-sub-sub-query *
* will return at most one row. */
SELECT 'X'
FROM HeaderTable HT
WHERE HT.HeaderKey = DT.HeaderKey
AND HT.HeaderField1 = ...
AND HT.HeaderField2 = ...)
Run Code Online (Sandbox Code Playgroud)
进入类似的东西:
SELECT ISNULL(SUM(DetailField), 0)
FROM DetailTable DT
WHERE DT.ForeignKey = ...
AND (SELECT HT.HeaderField1, …Run Code Online (Sandbox Code Playgroud) 我有一个存储过程,可以执行以下操作:
IF @Param = '1'
SELECT HT.HeaderKey, HT.Description,
(SELECT SUM(E1) -- E1 is actually a complex expression
FROM DetailTable DT INNER JOIN ...
INNER JOIN ...
INNER JOIN ...
WHERE DT.HeaderKey = HT.HeaderKey)
FROM HeaderTable HT
ELSE IF @Param = '2'
SELECT HT.HeaderKey, HT.Description,
(SELECT SUM(E2) -- E2 is yet another complex expression
FROM DetailTable DT INNER JOIN ... -- Here, DetailTable is not
INNER JOIN ... -- joined to the same tables
INNER JOIN ... -- as in the …Run Code Online (Sandbox Code Playgroud) JavaScript或jQuery是否有一个函数返回一个数组的元素,该数组的索引等于另一个数组中给定值的位置?(我可以写自己的,但我不想重新发明轮子.)
就像是:
function vlookup(theElement, array1, array2) {
$.each(array1, function(index, element) {
if (element === theElement)
return array2[index];
});
return null;
}
Run Code Online (Sandbox Code Playgroud)
但是,嗯...在标准库中.
我需要在运行Apache的Windows机器上安装PHP 5.3.x(最好是x> = 4).不幸的是,在PHP下载页面中,我找不到任何用VC6编译的PHP 5.3.x. 所以...
请考虑以下情形:
Foo,Bar和Baz.Foo必须与a Bar或a 相关联Baz,但不能同时与两者相关联.该方案已按以下方式实施:
Foo,Bar和Baz.Foo有两个外键领域:Bar_ID和Baz_ID.NULL.现在我想建立一个查询显示的列表FooS,其中包括的说明Bar或Baz每个Foo关联到.实际上,a的描述Bar是Bar表中相应行的字段的非常复杂的公式.这同样适用于Baz.
我当前的查询如下所示:
SELECT Foo.*,
CASE
WHEN Foo.Bar_ID IS NOT NULL THEN
-- a formula, say...
ISNULL(Bar.LotNumber + '-', '') + Bar.ItemNumber
WHEN Foo.Baz_ID IS NOT NULL THEN
-- another formula, say...
ISNULL(Baz.Color + …Run Code Online (Sandbox Code Playgroud) 我有下表:
CREATE TABLE X (
A SOMETYPE NOT NULL,
B SOMETYPE NOT NULL,
C SOMETYPE NULL,
PRIMARY KEY (A,B),
FOREIGN KEY (A,C) REFERENCES X (A,B)
);
Run Code Online (Sandbox Code Playgroud)
存储的实体X是按层次结构组织的:如果(A1,B1,C1)存在一行,C1 IS NOT NULL那么它被认为是(A1,C1,C2)任何东西的"子" C2.由于项目不能自行下降,我想将循环分层序列存在为非法:
-- legal
INSERT INTO X (A1,B1,NULL);
INSERT INTO X (A1,B2,B1);
INSERT INTO X (A1,B3,B2);
INSERT INTO X (A1,B4,B2);
-- currently legal, but I want to make it illegal
UPDATE X SET C = B1 WHERE B = B1; /* B1-B1 …Run Code Online (Sandbox Code Playgroud) 我正在尝试根据Lehman 和 Yao 在本文中建议的数据结构(B链接树)和算法来实现数据库索引。在第 2 页,作者指出:
磁盘分区为固定大小的部分(物理页;在本文中,这些对应于树的节点)。这些是进程可以读取或写入的唯一单元。[强调我的](...)
(...) 允许进程锁定和解锁磁盘页面。这个锁赋予该进程对该页面的独占修改权;此外,进程必须锁定页面才能修改该页面。(...)锁 不会阻止其他进程读取锁定的页面。[强调我的]
我不完全确定我的解释是正确的(我不习惯阅读学术论文),但我认为可以从强调的句子中得出结论,作者的意思是读取和写入页面的操作被假定为“原子” ,从某种意义上说,如果进程 A 已经开始读取(相应地写入)页面,则另一个进程 B 可能不会开始写入(相应地读取)同一页面,直到 A 完成其读取(相应地写入)操作. 多个进程同时读取同一个页面当然是一个合法的条件,因为多个进程同时在不同的页面上执行任意操作(页面 P 上的进程 A,页面 Q 上的进程 B,页面 R 上的进程 C,等等。 )。
我的解释正确吗?
我可以假设 POSIX'read()和write()系统调用在上述意义上是“原子的”吗?我是否可以依靠这些具有一些内部逻辑的系统调用来根据文件描述符的位置和要读取或写入的块的指定大小来确定是否应该暂时阻止特定read()或write()调用?
如果上述问题的答案是“否”,我应该如何推出自己的锁定机制?
Noob问题.
我正在开发一个使用有状态Web服务的PHP Web站点.基本上,我的网站的"控制流程"如下:
我的问题是Web站点在请求之间丢失了Web Service的状态.如何使网站跟踪Web服务的状态?我正在使用PHP的标准SoapClient类.
我已经尝试将SoapClient对象序列化为会话变量:
# ws_client.php
<?php
function get_client()
{
if (!isset($_SESSION['client']))
$_SESSION['client'] = new SoapClient('http://mydomain/MyWS/MyWS.asmx?WSDL', 'r');
return $_SESSION['client'];
}
function some_request($input1, $input2)
{
$client = get_client();
$params = new stdClass();
$params['input1'] = $input1;
$params['input2'] = $input2;
return $client->SomeRequest($params)->SomeRequestResult;
}
function stateful_request($input)
{
$client = get_client();
$params = new stdClass();
$params['input'] = $input;
return $client->StatefulRequest($params)->StatefulRequestResult;
}
?>
# page1.php
<?php
session_start();
$_SESSION['A'] = some_request($_POST['input1'], $_POST['input2']);
session_write_close();
header('Location: …Run Code Online (Sandbox Code Playgroud) 是否需要以下结构?
using (Something something = new Something())
{
try
{
}
finally
{
something.SomeCleanup();
}
}
Run Code Online (Sandbox Code Playgroud)
或者,是否应在隐式调用中执行所有清理任务something.Dispose()?
这是违规代码:
public static DataTable GetDataTable(string cmdText, IEnumerable<Parameter> parameters)
{
// Create an empty memory table.
DataTable dataTable = new DataTable();
// Open a connection to the database.
using (SqlConnection connection = new SqlConnection(ConfigurationTool.ConnectionString))
{
connection.Open();
// Specify the stored procedure call and its parameters.
using (SqlCommand command = new SqlCommand(cmdText, connection))
{
command.CommandType = CommandType.StoredProcedure;
SqlParameterCollection parameterCollection = command.Parameters; …Run Code Online (Sandbox Code Playgroud) sql-server ×3
php ×2
sql ×2
.net ×1
apache ×1
b-tree ×1
concurrency ×1
dom ×1
forms ×1
html ×1
javascript ×1
jquery ×1
posix ×1
session ×1
soap-client ×1
subquery ×1
try-finally ×1
using ×1
web-services ×1
xhtml ×1