我正在尝试获取尚未过期的优惠券.我在我的控制器中有这个:
public function coupons() {
$this->paginate['Coupon']=array(
'limit'=>9,
'order'=>'RAND()',
'conditions'=>array(
'Coupon.end_date'=>??????)
);
$c=$this->paginate('Coupon');
$this->set('allcoupons', $c);
}
Run Code Online (Sandbox Code Playgroud)
我需要它来返回截至今天未过期的所有记录.end_date是DATE格式.我不知道如何要求蛋糕查看end_date并将其与今天进行比较,并在paginate方法中进行.
该simple_html_dom库非常适合获取已知属性,但是有没有办法获取元素的所有属性列表?
例如,如果我有:
<div id="test" custom1="custom" custom2="custom">
Run Code Online (Sandbox Code Playgroud)
我很容易得到id:
$el = $html->find('div');
$id = $el->id;
Run Code Online (Sandbox Code Playgroud)
但是,它是否有可能获得custom1,custom2如果他们提前不知道?理想情况下,该解决方案将产生的阵列NVP的所有属性(id,custom1,custom2).
我有一个应用程序(不是我的编码),其中有很多水晶报告。我面临的问题是,每次我打开水晶报告时,它都会要求输入登录用户名和密码。
经过一番搜索后,我发现我必须在运行时设置报告的连接信息,并且我找到了一些解决方案,但是当我查看应用程序的代码时,我没有找到我所期望的。
frmviewrpt(具有水晶报表查看器的表单)有这样的东西:
RptProBalance rptProductBalance = new RptProBalance();
rptProductBalance.RecordSelectionFormula = getBalanceRptSelection();
rptProductBalance.Refresh();
allReportViewer.ReportSource = rptProductBalance;
Run Code Online (Sandbox Code Playgroud)
RptProBalance()(从 RptProBalance.rpt 文件扩展的 cs 文件):
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace minfatora {
using System;
using System.ComponentModel;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;
using CrystalDecisions.CrystalReports.Engine;
public class RptProBalance : ReportClass {
public RptProBalance() {
} …Run Code Online (Sandbox Code Playgroud) 我正在从mysql数据库填充下拉菜单.它运作良好,但我希望它不重复价值观.(即如果某个值在数据库中是N次,则在下拉列表中只出现一次)
这是我的代码:
<?php
mysql_connect('host', 'user', 'pass');
mysql_select_db ("database");
$sql = "SELECT year FROM data";
$result = mysql_query($sql);
echo "<select name='year'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['year'] . "'>" . $row['year'] . "</option>";
}
echo "</select>";
?>
Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试设置一个.htaccess和一个.htpasswd文件,以查看用户是否可以访问特定目录.当新用户注册时,他们的密码使用PHP md5()函数加密,然后使用其他登录信息存储在数据库中.我想.htpasswd动态地将一些加密密码添加到我的文件中,以便他们可以进入子成员部分.我遇到了麻烦,因为该.htpasswd文件可以使用该crypt()功能加密的密码,但我不知道如何使用它们的md5加密密码.
我目前正在研究一个drupal 7项目.我为某种内容类型编写了一个自定义模板.文件名称正确,node--type.tpl.php并且也正确显示.但其他区域和区块不可见.其他自定义模板显示所有区域和块.我想提两件事,
我使用RegEx ^[0-9]+$"只允许数字.我也想允许连字符-和空格.
任何人都可以帮我修改RegEx吗?
我使用以下JS代码来实现相同的目的,但是这样,如果用户正在复制和粘贴文本,那么按键就不会被记录.
//Allowed characters are : 8 = Back space,
//9 = Horizontal tab, 27 = esc, 127 = Delete,
//13 = Enter digits = 48 to 57, 45 = hypen
$('#PostalCode').keypress(function (e) {
var key = (e.keyCode ? e.keyCode : e.which);
return (key == 8 || key == 9 || key == 127 || key == 27 || key == 13 || key == 45 || (key >= 48 && key <= 57));
});
Run Code Online (Sandbox Code Playgroud) 这是我的代码.
NSArray *pathSong = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *toPath = [[pathSong objectAtIndex:0] stringByAppendingPathComponent:@"Songs"];
NSString *fromPath=[[pathSong objectAtIndex:0] stringByAppendingPathComponent:@"abc"];
NSString *strdestination = [fromPath stringByAppendingPathComponent:@"sg.mp3"];
NSError *Error;
if([[NSFileManager defaultManager]fileExistsAtPath:strdestination]){
if([[NSFileManager defaultManager]copyItemAtPath:strdestination toPath:toPath error:&Error]==NO){
UIAlertView *Alert=[[UIAlertView alloc]initWithTitle:@"copy" message:[NSString stringWithFormat:@"%@",Error] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[Alert show];
}
else{
UIAlertView *Alert=[[UIAlertView alloc]initWithTitle:@"Not copy" message:[NSString stringWithFormat:@"%@",Error] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[Alert show];
}
}
Run Code Online (Sandbox Code Playgroud)
我收到错误徽标:
Error Domain = NSCocoaErrorDominCode = 516"操作无法完成.(Cocoa arrow 516.)"userInfo = 0x681abf0
NSUnderlyingError = 0x681b920"操作无法完成.File exists"
abc文件夹没有歌曲名称"sg.mp3"但我仍然得到文件存在错误.我不知道我错在哪里?
因此,当我测试一个用DataRow参数创建的方法时,我发送了一个参数并在方法中修改了它.在那之后,我的原始版本DataRow变成了最后的方法.我意识到这是因为它DataRow是一种"参考类型",对我来说是新的.
我现在知道在使用方法时我可以在其他数据类型之前使用"ref"或"out",以便DataRow发生与示例相同的效果.但我的问题是,默认情况下哪些数据类型是引用类型?当我将另一种数据类型传递给方法并使原始值发生变化时,我不想让人措手不及.