我收到错误:
remote: error: cannot run hooks/post-receive: No such file or directory
Run Code Online (Sandbox Code Playgroud)
当试图推送到远程.post-receivce文件存在于正确的位置(testnew.git/hooks)并包含:
#!/bin/bash2
export GIT_DIR=/var/www/testnew/testnew/.git/
export GIT_WORK_TREE=/var/www/testnew/testnew/
cd /var/www/testnew/testnew/
echo "here we go..."
git fetch
git merge origin/master
git submodule update --init --recursive
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下方式设置接收后的权限:
chmod a+x post-receive
Run Code Online (Sandbox Code Playgroud)
但这会产生同样的错误.将权限设置为755会删除错误,但脚本不会运行.
我想在foreach中的数组中创建键值对.这是我到目前为止:
function createOfferUrlArray($Offer) {
$offerArray = array();
foreach ($Offer as $key => $value) {
$keyval = array($key => $value[4] );
array_push($offerArray,$keyval);
}
return $offerArray;
}
Run Code Online (Sandbox Code Playgroud)
如果我在foreach中声明数组,它将在每次迭代时覆盖它,但是在foreach之外定义它也不起作用并导致三元组:
array[0] => key => value
array[1] => key => value
Run Code Online (Sandbox Code Playgroud)
我怎么做到这样我只得到像这样的键值对?
key => value
key => value
Run Code Online (Sandbox Code Playgroud) 我有一个javascript块用于显示我希望每隔一次在页面上包含的广告.
我正在使用Mustache作为我的模板语言,但无法解决如何包含js以便它作为脚本运行而不仅仅是作为字符串插入.
<script id="mustache-post-advert" type="text/mustache">
<article id="post-{{id}}" class="post">
{{{ <script type="text/javascript">GA_googleFillSlot("MPU")</script> }}}
</article>
</script>
Run Code Online (Sandbox Code Playgroud)
我已经尝试了三倍{我希望它会逃脱,但遗憾的是它没有.
我正在使用MCustomScrollBar ,但页面上有多个滚动条实例.我需要能够分别动态地.mCSB_container将<li>元素附加到每个滚动条.
这本质上是同一个问题,但是接受的答案是行不通的,因为它试图使用attr来获取id,其中类没有id.
<div id="titles" class="scroll-box" style="opacity: 1;">
<h2>Latest Titles</h2>
<ul class="scroll-horizontal mCustomScrollbar _mCS_1">
<div class="mCustomScrollBox mCSB_horizontal" id="mCSB_1" style="position:relative; height:100%; overflow:hidden; max-width:100%;">
<div class="mCSB_container" style="position: relative; left: 0px; width: 2860px;">
<li class="product-car"> My Car</li>
<li class="product-bike"> My Bike </li>
<li class="product-tree"> My Tree </li>
</div>
</div>
</ul>
</div>
<div id="titles" class="scroll-box" style="opacity: 1;">
<h2>Latest Houses</h2>
<ul class="scroll-horizontal mCustomScrollbar _mCS_2">
<div class="mCustomScrollBox mCSB_horizontal" id="mCSB_2" style="position:relative; height:100%; overflow:hidden; max-width:100%;">
<div class="mCSB_container" style="position: relative; left: 0px; width: …Run Code Online (Sandbox Code Playgroud) 我有一个XSL文档,其中插入了可变数量的文章.我需要文章的背景颜色交替 - "奇怪"然后"偶数"
<xsl:for-each select="newsletter/section/article">
<tr class="odd" style="background-color: #efefef;">
<td valign="top">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="link" />
</xsl:attribute>
<img align="left" valign="top" width="110"
style="padding: 0 4px 4px 0; border:0;">
<xsl:attribute name="alt">
<xsl:value-of select="title" />
</xsl:attribute>
<xsl:attribute name="src">
<xsl:value-of select="img" />
</xsl:attribute>
</img>
</xsl:element>
</td>
<td valign="top" style="padding: 4px 4px 18px 0;">
<strong>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="link" />
</xsl:attribute>
<xsl:value-of select="title"/>
</xsl:element>
</strong>
<br />
<xsl:value-of select="excerpt"/>
</td>
</tr>
</xsl:for-each>
Run Code Online (Sandbox Code Playgroud)
我看过这篇文章:通过XSL交替排行颜色的HTML表格
但我相信我的情况有所不同.我只需要在每次迭代时更改tr类.很抱歉奇怪的格式化,我似乎在浏览Chrome中的代码时遇到了问题.
我需要执行此查询:
SELECT * FROM (SELECT * FROM product WHERE car = 'large' ORDER BY onSale DESC) AS product_ordered GROUP BY type
Run Code Online (Sandbox Code Playgroud)
在Symfony2中使用实体管理器.
我的基本查询构建器将是:
$query = $em->getRepository('AutomotiveBundle:Car')
->createQueryBuilder('p')
->where('pr.car = ?1')
->andWhere('pr.status = 1')
->orderBy('pr.onSale', 'DESC')
->setParameter(1, $product->getName())
->groupBy('p.type')
->getQuery();
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何在子查询中添加.
我试过单独的查询并加入它像:
->andWhere($query->expr()->in('pr.car = ?1',$query2->getQuery()));
Run Code Online (Sandbox Code Playgroud)
但我得到:
Call to undefined method Doctrine\ORM\Query::expr()
Run Code Online (Sandbox Code Playgroud) 我有一个JSON对象数组,我正在尝试找出如何在Mustache.js中显示它们.数组的长度和内容可以变化.
例:
[ Object { id="1219", 0="1219", title="Lovely Book ", url= "myurl} , Object { id ="1220" , 0="1220 , title "Lovely Book2" , url="myurl2"}]
Run Code Online (Sandbox Code Playgroud)
我试过了:
$.getJSON('http://myjsonurl?type=json', function(data) {
var template = $('#personTpl').html();
var html = Mustache.to_html(template, data);
$('#test').html(html);
Run Code Online (Sandbox Code Playgroud)
和模板:
<script id="personTpl" type="text/template">
TITLE: {{#data}} {{title}} IMAGE: {{image}}
<p>LINK: <a href="{{blogURL}}">{{type}}</a></p> {{/data}}
</script>
Run Code Online (Sandbox Code Playgroud)
但这并没有显示任何东西.
我已经尝试将JSON放入一个数组中,然后使用以下内容直接访问它 products[1]:
$.getJSON("http://myjsonurl?type=json", function(json)
{
var products = [];
$.each(json, function(i, product)
{
var product =
{
Title:product.title,
Type:product.type,
Image:product.image
};
products.push(product);
;
});
var …Run Code Online (Sandbox Code Playgroud) 我试图在对象上使用PDO :: FETCH_CLASS.我正在使用命名空间,只需输入:
$result = $query->fetchAll(\PDO::FETCH_CLASS, 'Product');
Run Code Online (Sandbox Code Playgroud)
要么
$result = $query->fetchAll(\PDO::FETCH_CLASS, '\Product');
Run Code Online (Sandbox Code Playgroud)
导致PHP Product.php在应用程序的根目录中查找.
我可以使用以下方法成功实例化新产品:
$product = new Product();
Run Code Online (Sandbox Code Playgroud)
所以我知道我的名字间距正在起作用.
这不可能吗?或者我是否需要首先实例化产品然后从查询后填充它?
我有一张满是杂志的桌子,需要提取每本杂志的最新独特刊物.
我试过了
SELECT DISTINCT
magazine
FROM
product p
INNER JOIN
(SELECT
title, MAX(onSale) AS Latest
FROM
product
GROUP BY magazine) groupedp
Run Code Online (Sandbox Code Playgroud)
它返回不同的杂志,但不返回我需要的其他数据.
更新:
模式
-id----onsale----magazine
1 1/12/12 Fishing Mag
2 1/11/12 Fishing Mag
3 12/03/11 Pencil Sharpening Monthly
4 1/02/10 Pencil Sharpening Monthly
5 16/04/09 Homes in the Sky
Run Code Online (Sandbox Code Playgroud)
所以我希望返回的结果是:
-id----onsale----magazine
1 1/12/12 Fishing Mag
3 12/03/11 Pencil Sharpening Monthly
5 16/04/09 Homes in the Sky
Run Code Online (Sandbox Code Playgroud)