有没有办法重置一张桌子?
我的意思是不仅要删除所有行,还要将auto_incrementing ID重新设置为0?
我正在尝试保存订单,以及订单中的产品.
订单正在保存,但产品不是.
我有一张orders桌子,一张products桌子和一张orders_products桌子.
在我订的订单模型中 $hasAndBelongsToMany = 'Product';
在orders_products表我有几个额外的字段:order_id,product_id加price,quantity捕捉销售价格和销售数量.
我通过以下方式保存数据:
$这 - >命令中─>白水回收($数据);
以下是$ data的数据:
Array
(
[Order] => Array
(
[user_email] => st@kr.com
[billing_first] => Steve
... //more excluded
[total] => 5000
)
[Product] => Array
(
[0] => Array
(
[id] => 1
[price] => 5000.00
[quantity] => 1
)
)
)
Run Code Online (Sandbox Code Playgroud)
订单会保存到订单表中,但不会将任何内容保存到orders_products表中.我期望orders_products表保存[new_order_id], 1, 5000.00, 1
我收到了这个通知:
Notice (8): Undefined index: id …Run Code Online (Sandbox Code Playgroud) 未在MySQL中设置的日期时间字段将返回到0000-00-00 00:00:00
什么是确定日期是否未在PHP中设置的最佳方法?
没有,如果这些工作:
if($date) //will return true because it is a valid string
if(empty($date)) //will also return true.
if(strtotime($date)) //I thought this would work but it returns a negative number and is true.
Run Code Online (Sandbox Code Playgroud)
我可以用:
if($date == '0000-00-00 00:00:00')
Run Code Online (Sandbox Code Playgroud)
但是,如果我然后将列类型更改为日期,它将会中断.所以我也不喜欢这个.
我正在寻找类似的东西,is_date但我能找到的是一个名为checkdate的功能,似乎不是我想要的.
我想我可以使用:
if(strtotime($date) > 0)
Run Code Online (Sandbox Code Playgroud)
我没有看到任何明显的问题,但我仍然认为可能有更好的东西.
标准方式是什么?
我希望能够在CakePHP中从视图(或控制器,如果可能)添加元标记
我有一个类似的页面,/mycontroller/myview但是当使用以下过滤器访问它时:
/mycontroller/myview/page:2/max_price:500
然后我想添加meta no follow标签.
HtmlHelper类有一个meta方法.
当我这样称呼时:
$this->Html->meta('keywords', 'test test test', array('inline'=>false));
Run Code Online (Sandbox Code Playgroud)
它会创建一个这样的元标记:
<meta name="keywords" content="test test test" />
Run Code Online (Sandbox Code Playgroud)
但是,当我这样称呼时:
$this->Html->meta('robots', 'noindex, nofollow', array('inline'=>false));
Run Code Online (Sandbox Code Playgroud)
我自然会期望并希望它创造这个:
<meta name="robots" content="noindex, nofollow" />
Run Code Online (Sandbox Code Playgroud)
相反,我得到了这个:
<link href="http://www.example.com/mycontroller/noindex, nofollow" type="application/rss+xml" rel="alternate" title="robots" />
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
好的,首先,我将此行添加到我的.htaccess文件中,以便php引擎解析.xml文件中的php代码:
AddType application/x-httpd-php .php .php3 .phtml .html .xml
Run Code Online (Sandbox Code Playgroud)
之后,当我查看.xml文件时,我收到此PHP错误:
解析错误:在第1行的/var/www/vhosts/mydomain.com/httpdocs/test.xml中解析错误,意外的T_STRING
但是第1行甚至不是php,因为这是第1行:
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
谁能告诉我这是什么问题?
谢谢.
我需要基本上将它添加到我的页面:
<body onload="document.getElementById('WeddingBandBuilder').focus()">
Run Code Online (Sandbox Code Playgroud)
但是由于我的模板,我无法更改标签.那么有没有办法用<head>标签中的脚本做等效的事情呢?
谢谢!
我想使用日历的图像来显示/隐藏jquery datepicker.基于文档看起来我需要设置buttonImage和buttonImageOnly,我有.日期选择器正在工作但它始终可见.这是我的代码:
<script type="text/javascript">
$(document).ready(function(){
$("#datepicker").datepicker({
altField: '#from',
altFormat: 'yymmdd',
buttonImage: 'datepicker.png',
buttonImageOnly: true,
defaultDate: <?=getDaysFromToday($_GET['from'])?>,
showOn: 'focus'
});
});
$('#datepicker').datepicker({
onSelect: function(dateText, inst) {
$("#myform").submit();
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
此外,我试图让它在您选择日期时提交表单,我似乎也无法让它工作.
难道我做错了什么?
谢谢!
我正在尝试学习Java,我正在阅读一个教程,说的是这样的:
while (N <= 0) {
TextIO.put("The starting point must be positive. Please try again: ");
N = TextIO.getlnInt();
}
Run Code Online (Sandbox Code Playgroud)
看起来当您要求用户输入时,它会暂停,直到收到响应为止?我已经习惯了这些异步发生的事情.这对Java来说是正常的吗?或者你可以两个都做?
谢谢.
我有一些页面,我不希望用户能够直接访问.
我有这个功能,我提出了哪些工作:
function prevent_direct_access()
{
if($_SERVER['REQUEST_URI'] == $_SERVER['PHP_SELF'])
{
//include_once('404.php');
header("Location: 404.php");
}
}
Run Code Online (Sandbox Code Playgroud)
这正是我想要的,URL不会改变但内容会改变.但是我想知道是否有一些东西我需要添加来告诉搜索引擎这是一个404而不是索引它.请记住,我不希望URL改变.
谢谢!
我现在有一个AIR应用程序已完成一半.今天客户告诉我,他不希望在他的任务栏中显示一个标签.通过使它们轻量化,我已经为新窗口制作了这个.我不知道如何使主窗口轻量级.如果没有办法,是否有解决办法,比如不是没有主窗口而只是打开轻量级窗口,不知道怎么办呢?有人知道怎么做吗?
谢谢!
php ×4
cakephp ×2
cakephp-1.3 ×2
mysql ×2
.htaccess ×1
air ×1
apache-flex ×1
asynchronous ×1
date ×1
datepicker ×1
java ×1
javascript ×1
jquery ×1
sql ×1
xml ×1