我有一个SQL Server 2008数据库,表中包含以下信息:
ID Name
-- ----
1 John
2 Jill
3 John
4 Phil
5 Matt
6 Jill
Run Code Online (Sandbox Code Playgroud)
我想在下拉列表中显示唯一的名称.因此,我只需要一个与唯一名称相关联的ID.我知道它很脏.我没有制造这个烂摊子.我只需要使用其中一个ID的唯一名称.如何编写将执行此操作的查询?我知道由于ID字段,以下内容不起作用.
SELECT DISTINCT
[ID], [Name]
FROM
MyTable
Run Code Online (Sandbox Code Playgroud) 我收到以下警告:
payment_method.rb:11: warning: multiple values for a block parameter (0 for 1)
payment_method.rb:12: warning: multiple values for a block parameter (0 for 1)
Run Code Online (Sandbox Code Playgroud)
payment_method.rb第11和12行:
class PaymentMethod < ActiveRecord::Base
...
named_scope :expiring_next_month, lambda {|pm| {:conditions => {:ed => DateTime.now.beginning_of_month}}}
named_scope :expired, lambda {|pm| {:conditions => ["ed < ?", DateTime.now.beginning_of_month]}}
...
end
Run Code Online (Sandbox Code Playgroud)
我在这里想念什么?
我碰巧遇到了以下函数指针.
char (*(*x())[])();
Run Code Online (Sandbox Code Playgroud)
它看起来像以下格式的函数指针数组,但我看不出f - >(*x())的含义.如何解释这个凌乱的函数指针?
char (*f[])();
Run Code Online (Sandbox Code Playgroud)
在John Bode的帮助下,我举了一个例子如下.
#include <stdio.h>
char foo() { return 'a'; }
char bar() { return 'b'; }
char blurga() { return 'c'; }
char bletch() { return 'd'; }
char (*gfunclist[])() = {foo, bar, blurga, bletch};
char (*(*x())[])()
{
static char (*funclist[4])() = {foo, bar, blurga, bletch};
return &funclist;
}
int main()
{
printf("%c\n",gfunclist[0]());
char (*(*fs)[4])();
fs = x();
printf("%c\n",(*fs)[1]());
}
Run Code Online (Sandbox Code Playgroud)
我可以得到预期的结果.
smcho@prosseek temp2> ./a.out a b
而且,您可以在此处找到更好的实施方案.
我正在尝试将HSB颜色转换为RGB.我这样做的方式是
System.Windows.Media.Color winColor = value;
System.Drawing.Color drawColor = System.Drawing.Color.FromArgb(winColor.R, winColor.G, winColor.B);
Hue = (byte)(drawColor.GetHue()*255);
Saturation = (byte)(drawColor.GetSaturation()*255);
Luminosity = (byte)(drawColor.GetBrightness()*255);
Run Code Online (Sandbox Code Playgroud)
我发现,当我有FF0000,它将被转换为H = 0, S = 255, L = 127转换为RGB FF0E0E.我觉得Luminosity应该是120?或者我是否让整个HSB错误?当我在Photoshop中查看颜色选择器时,Hue为0-360度,饱和度,亮度为0-100%.我的HSB值介于0到255之间,我做错了吗?
如果我声明这个数组......
string[,] a = {
{"0", "1", "2"},
{"0", "1", "2"},
{"0", "1", "2"},
{"0", "1", "2"},
};
Run Code Online (Sandbox Code Playgroud)
然后我可以测量长度
a.Length
Run Code Online (Sandbox Code Playgroud)
这是12.如何测量阵列的尺寸?如果我试试......
a[0].Length
Run Code Online (Sandbox Code Playgroud)
我得到Wrong number of indices inside []; expected 2.是什么赋予了?
我正在使用PHP和Mysql设计订单站点.在最后阶段,用户被给予Paypal按钮以支付他所做的订单.因此,项目名称,值是变量.这些值是变量,我不能使用Paypal的加密按钮.我必须使用非加密按钮或在将其显示给用户之前对其进行加密.
我希望出于安全原因加密它.我想知道如何在我的服务器上执行此操作.
我想离开这个:
if($var == 3 || $var == 4 || $var == 5 || $var =='string' || $var == '2010-05-16') {
// execute code here
}
Run Code Online (Sandbox Code Playgroud)
对此:
if($var == (3, 4, 5, 'string', '2010-05-16')) { // execute code here }
Run Code Online (Sandbox Code Playgroud)
看起来非常冗余以便继续输入$var,我发现它使得阅读有点麻烦.PHP中有没有办法以这种方式简化它?我在这里阅读一篇文章,在使用XQuery时你可以使用=运算符$var = (1,2,3,4,5)等.
一个简单的问题:是否有一个很好的参考实现,使用ASP.NET MVC与ORM,ViewModels和EditModels(理想情况下使用Automapper)?
我理解使用这些特定于特定目标的模型的好处,但对我到目前为止使用这些代码所编写的代码的结果并不太满意.一个简单的参考应用程序,展示了如何以及在MVC工作流程中应用这些方面将会很棒.
asp.net-mvc viewmodel automapper reference-implementation editmodel
Array
(
[0] => 'hello'
[1] => 'there'
[2] =>
[3] =>
[4] => 3
)
// how to get the number 5?
Run Code Online (Sandbox Code Playgroud) 目前我遇到了一个小问题:
我想为nekoVM创建FastCGI/CGI绑定.这是通过编写VM加载的一些线索C/C++代码来完成的.我想使我的绑定行为尽可能与neko native API(mod_neko,mod_tora)兼容.使用mod_neko,可以获取客户端发送的所有HTTP头.
据我所知,只有通过调用才能获得FastCGI的HTTP头getenv('header_name').要使用此功能,您需要知道所有标题的名称.
我的问题:是否有可能获得客户端发送的所有标头?