String months[] = { null , "Jan" , "Feb" , "Mar" , "Apr",
"May", "Jun", "Jul", "Aug", "Sep", "Oct",
"Nov", "Dec" };
try
{
System.out.print("Enter month <1 for Jan - 12 for Dec>: ");
m = input.nextInt();
MonthData();
}
catch(Exception e)
{
System.out.println("Invalid month!"); //error message to inform user of wrong input
}
break;
static void MonthData()
{
System.out.println("----------------------------------------");
System.out.println(months[m]+" Expenditure <max 10 items>");
try
{
for(int i=0; i<10; i++)
{
System.out.print("Enter item "+(i+1)+" <Press ENTER to exit> : "); …Run Code Online (Sandbox Code Playgroud) 是否可以在Drupal模块中创建自己的钩子以供其他Drupal模块使用?如果没有,Drupal中是否有一个机制可供第三方开发人员提供钩子?如果到目前为止一切都没有,核心中的钩子列表实现了什么?
据我所知,Drupal模块可以处理类似系统的事件,称为钩子.创建新模块时,可以创建实现钩子的函数.例如,有一个hook_delete钩子.如果在模块中实现了一个功能
function mymodule_delete($node)
{
}
Run Code Online (Sandbox Code Playgroud)
删除节点时将调用此函数.
我想知道的是,作为第三方模块开发人员,有没有办法创建我自己的钩子.比方说,hook_alanskickbutthook其他模块开发人员可以订阅这个钩子.
如果可以,你怎么做?我查看了官方文档并且在那里找不到多少,当我开始探索Drupal源代码时,我仍然感到有些晕眩(我理解递归,但是没有花太多时间考虑递归问题).我们欢迎完整的解决方案,但我很高兴能够指出正确的方向.
我想使用web.config中的compileroptions标记来版本化我的DLL文件.是否可以使用相对路径?如果没有,是否有使用相对路径的选项?我正在使用CruiseControl.
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp"
extension=".cs"
warningLevel="4"
compilerOptions="NEED_ARELATIVE_PATH\Properties\AssemblyInfo.cs"
type="Microsoft.CSharp.CSharpCodeProvider,System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion"
value="v4.0"/>
<providerOption name="WarnAsError"
value="false"/>
</compiler>
</compilers>
</system.codedom>
Run Code Online (Sandbox Code Playgroud) 有没有人cksum在awk/gawk中实现POSIX 1003.2 compiliant CRC算法(作为输出)?我需要对内存中的字符串(而不是整个文件)执行校验和,并且调用shell来进行调用cksum是非常慢且昂贵的.
我的总体需求是生成一个10位数或更少的数字校验和.其他哈希/ CRC功能也可以工作,任何人有什么方便吗?
谷歌搜索和awk.info的扫描结果没什么有趣的.
让我解释.我有一个简单的查询,当我在phpmyadmin上测试时,它可以工作,但它不会在我的Web应用程序中返回正确的答案.
这是运行查询的函数:
function GetProductsFromCategoryId($categoryId)
{
global $db;
$query = '
SELECT *
FROM `products`
WHERE categoryID = 3';
try {
$statement = $db->prepare($query);
//$statement->bindValue(':categoryId', $categoryId);
$statement->execute();
$result = $statement->fetch();
$statement->closeCursor();
return $result;
} catch (PDOException $e) {
$error_message = $e->getMessage();
display_db_error($error_message);
}
}
Run Code Online (Sandbox Code Playgroud)
通常categoryID = $ categoryID,但我用"3"硬编码,因为我想看到结果.还有整个其他数据库文件处理连接,我可以发布它们,如果你想,但其他功能工作正常.这是我在Murach的php book ch 24中使用的模板.这个函数是我自己的,略有修改.
对于SELECT*,该函数应为每个产品返回2个数组,稍后当我从phpmyadmin发布结果时您会看到.相反,它只返回一个产品的1个数组.
这是我在phpmyadmin中运行的查询:
SELECT * FROM `products` WHERE categoryID=3;
Run Code Online (Sandbox Code Playgroud)
结果是:
9 3 ludwig Ludwig 5-piece Drum Set with Cymbals This product includes a Ludwig 5-piece drum set an... 699.99 30.00 2010-07-30 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Grid.IsSharedSizeScope来排列由GridControl中第一列中某些控件旁边的ItemsControl显示的数据绑定控件.
问题是我不能阻止控制器不断垂直增长.
如何在不设置MaxHeight属性的情况下阻止他们这样做.我已尝试在不同的地方设置VerticalAlignment和VerticalContentAlignment的不同设置,但无法弄明白.
<Grid Grid.IsSharedSizeScope="True" >
<Grid.RowDefinitions>
<RowDefinition SharedSizeGroup="RowOne" />
<RowDefinition SharedSizeGroup="RowTwo" />
<RowDefinition SharedSizeGroup="RowThree" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<SomeControl Grid.Row="0" Grid.Column="0" />
<SomeControl Grid.Row="1" Grid.Column="0" />
<ItemsControl Grid.Row="0" Grid.Column="1" Grid.RowSpan="3" ItemsSource="{Binding Path=SomeSource}" ItemsPanel="{StaticResource MyHorizontalStackPanel}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition SharedSizeGroup="RowOne" />
<RowDefinition SharedSizeGroup="RowTwo" />
<RowDefinition SharedSizeGroup="RowThree" />
</Grid.RowDefinitions>
<SomeControl Grid.Row="0" />
<SomeControl Grid.Row="1" />
<SomeControl Grid.Row="2" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
Run Code Online (Sandbox Code Playgroud) 如果两个模块在Drupal中实现相同的钩子,系统是否有办法定义钩子函数的调用顺序,或者只是绘制/字母顺序的运气?或者是其他东西?或者我的问题是否表明我误解了一些让我看起来愚蠢的基本方式?
我不是100%确定级联删除是如何工作的.
我有简单的表,看起来像这样
用户User_ID
ExtendedUser User_ID
评论User_Id
帖子User_ID
我基本上有大量的表引用User的User_ID.我想在一个表上设置级联删除,以便我可以删除User对象并确保删除所有引用User的表.
但是,我的理解是我需要在每个引用User的表上设置删除操作.我需要在每个子表上设置"级联删除".我的理解是否正确?
更新:看起来我必须为每个关系设置它.我应该在哪里将这些关系视为"存储"?也许我的观念不对.
看起来我可以使用父表中的管理工作室为每个关系设置所有参照完整性规则.
如何忽略在build我的项目的根目录中调用的文件夹,但不能忽略build在其他地方调用的文件夹?
即
/myprog/.hgignore
/myproj/make
/myproj/build <-ignore this
/myproj/lib/somelib/build <- dont ignore this
Run Code Online (Sandbox Code Playgroud) 我是一个shell脚本新手,所以我必须做一些愚蠢的事情,为什么这不会起作用:
#!/bin/sh
myFile=$1
while read line
do
ssh $USER@$line <<ENDSSH
ls -d foo* | wc -l
count=`ls -d foo* | wc -l`
echo $count
ENDSSH
done <$myfile
Run Code Online (Sandbox Code Playgroud)
应打印两行,每行应具有相同的值......但它们不具有相同的值.第一个print语句[ls -d foo*|的结果 wc -l]具有正确的值,第二个print语句不正确,它始终打印为空白.我需要做一些特殊的事情来将值分配给$ count吗?
我究竟做错了什么?
谢谢