标签: behavior

Doctrine:如何从侦听器中的select查询中删除where子句的一部分(preDqlSelect)?

我的侦听器是行为的一部分,应该删除任何被调用的select查询的where子句中的所有is_published检查.在子句中添加一个部分非常简单,但如何删除一个.

有一些函数Doctrine_Query->removeDqlQueryPart('where'),但是删除了完整的where子句,而我只需要'is_published = ?'删除部分.

但是,我可以用某种方式手动处理这个,使用正则表达式或其他东西.但棘手的部分是,如何删除'?'所代表的参数 来自相应的参数数组(可检索Doctrine_Query->getRawParams()).

所以我问,是否有一种简洁的方法来转换这种查询:
...FROM Video v WHERE v.is_published = ? AND v.start_date < ? AND v.end_date > ?

对于这个剥离的,没有弄乱问号代表的params:
...FROM Video v WHERE v.start_date < ? AND v.end_date > ?

这当然只是一个简单的例子,我的查询有点复杂.不幸的是,由于symfony框架,我坚持使用doctrine 1.0.x.

php doctrine behavior listener

6
推荐指数
2
解决办法
8462
查看次数

C# - foreach显示奇怪的行为/没有问题

今天我编写了一个使用两个嵌套的foreach循环的函数.看到后,它没有像预期的那样工作,我调试了它.但我没有看到错误,并且不认为一个简单的错误可能导致我注意到的行为.

该部分看起来像这样:

foreach(MyClass cItem in checkedListBoxItemList.Items)
{
   foreach(MyClass cActiveItem in ActiveItemList)
   {
      if (cActiveItem.ID == cItem.ID) /*...check checkbox for item...*/;
   }
}
Run Code Online (Sandbox Code Playgroud)

可以说,checkedListBoxItemList.items包含4个MyClass类型的项目,而ActiveItemList是包含2个Items的List <MyClass>.

调试器跳转到外部foreach,到达内部foreach,执行if 2次(每个cActiveItem一次)并到达外部foreach的末尾.现在,调试器跳回到foreach外部的头部.但是调试器不是启动外部foreach的第二轮,而是突然跳转到MyClass.ToString()方法.我可以通过这个方法4次(checkedListBoxItemList.Items中的项目数),然后......没有.Visual Studio向我展示了我的窗体,并且不再继续使用foreach.

将代码更改为时

int ListCount = checkedListBoxItemList.Items.Count;
for(int i=0; i<ListCount; i++)
{
   MyClass cItem = checkedListBoxItemList.Items[i] as MyClass;
   foreach(MyClass cActiveItem in ActiveItemList)
   {
      if (cActiveItem.ID == cItem.ID) /*...check checkbox for item...*/;
   }
}
Run Code Online (Sandbox Code Playgroud)

一切正常,按照假设.我向同事展示了这个问题,但他也不明白,发生了什么.我不明白为什么调试器会跳转到MyClass.ToString()方法.我用F10来逐步完成,所以不需要离开这个功能.甚至,如果有原因,为什么foreach循环不会继续?

我使用Visual Studio 2010,如果这是任何问题.

请告诉我发生了什么.谢谢.

c# debugging foreach behavior

6
推荐指数
1
解决办法
1557
查看次数

Enum的DataStateBehavior而不是bool?串?

在WPF中有一种简单的方法将VisualStates绑定到枚举值吗?有点像DataStateBehavior,但对于Enum?

data-binding wpf behavior

6
推荐指数
1
解决办法
1849
查看次数

为什么Visual Studio 2010会随机更改web.configs的项目文件?

为什么Visual Studio 2010会随机更改web.configs的项目文件?

使用Mercurial我经常在提交窗口中看到差异

-    <Content Include="Admin\Web.config" />

+    <Content Include="Admin\Web.config">
+      <SubType>Designer</SubType>
+    </Content>
Run Code Online (Sandbox Code Playgroud)

它将不断翻转子类型以存在或不存在.

random behavior projects-and-solutions visual-studio-2010

6
推荐指数
1
解决办法
1339
查看次数

在Python解释器中,>> >> some_object`和`>>>打印some_object`有什么区别?

在解释器中,您只需a = [1, 2, 3, u"hellö"]在解释器提示符处写入对象的名称,例如列表,如下所示:

>>> a
[1, 2, 3, u'hell\xf6']
Run Code Online (Sandbox Code Playgroud)

或者你可以这样做:

>>> print a
[1, 2, 3, u'hell\xf6']
Run Code Online (Sandbox Code Playgroud)

这似乎相当于列表.目前我正在使用hdf5来管理一些数据,我意识到上面提到的两种方法之间存在差异.鉴于:

with tables.openFile("tutorial.h5", mode = "w", title = "Some Title") as h5file:
    group = h5file.createGroup("/", 'node', 'Node information')
    tables.table = h5file.createTable(group, 'readout', Node, "Readout example")
Run Code Online (Sandbox Code Playgroud)

的输出

print h5file
Run Code Online (Sandbox Code Playgroud)

不同于

>>> h5file
Run Code Online (Sandbox Code Playgroud)

所以我想知道是否有人可以解释Python在这两种情况下的行为差异?

python printing behavior

6
推荐指数
1
解决办法
236
查看次数

cakephp - 模型和行为有什么区别?

我理解这种行为应该扩展模型并为其添加功能,但在大多数情况下,胖模型的想法使行为无用,不是吗?

并且,甚至首选,忽略我的第一段,只是回答 - 请 - 标题中的问题,并添加一个示例,以明确

谢谢

cakephp model behavior

6
推荐指数
1
解决办法
6285
查看次数

在Matlab中关闭"智能行为"

在Matlab上有一件我不喜欢的东西:它有时会过于聪明.例如,如果我有一个负平方根

a = -1; sqrt(a)
Run Code Online (Sandbox Code Playgroud)

Matlab不会抛出错误,而是静默地切换到复数.负对数也会发生同样的情况.这可能导致在更复杂的算法中难以发现错误.

类似的问题是Matlab"解决"静默非二次线性系统,如下例所示:

A=eye(3,2); b=ones(3,1); x = A \ b
Run Code Online (Sandbox Code Playgroud)

显然x不满足A*x==b(它解决了最小二乘问题).

是否有可能关闭"功能",或者至少让Matlab在这种情况下打印警告信息?在许多情况下,这确实会有很大帮助.

matlab warnings behavior

6
推荐指数
1
解决办法
1915
查看次数

从app store安装新版本后的iOS应用行为

我在应用程序商店的iPhone中安装了一个iOS应用程序,现在如果我在应用程序商店有相同应用程序的更新版本1.1,我从旧版本1.0获得某种信息警报(新版本可用... ).

如果我点击alertview的确定按钮,它会将我重定向到浏览器中的新应用程序链接.然后我下载我的新版本.

请提供以下问题的答案:

  1. 它会取代旧版本吗?
  2. 它会替换文档路径上的sqlite和image文件夹吗?(两个版本都有相同的命名sqlite文件,比如abc.sqlite1.0和相同的文件夹名称,比如imagesToBeCopied)
  3. 它是否会为同一实体添加新行的sqlite权限行?
  4. 如何从应用商店再次安装1.0版?无论如何都可以得到它吗?

请提供您宝贵的答案,这可以帮助我找到解决方案.

谢谢.

behavior version ios

6
推荐指数
1
解决办法
436
查看次数

在foreach-loop奇怪行为中的php key()或在foreach循环中获取下一个键

看这个:

<?php
    $array = array('a' => '…', 'b' => '…', 'c' => '…', 'd' => '…', 'e' => '…', 'f' => '…');
    foreach ($array as $key => $val){
        echo "current key: $key, next key: ".key(($array))."<br>";
    }
?>
Run Code Online (Sandbox Code Playgroud)

OUTPUT:

current key: a, next key: b
current key: b, next key: c
current key: c, next key: d
current key: d, next key: e
current key: e, next key: f
current key: f, next key: a
Run Code Online (Sandbox Code Playgroud)

我正在寻找一个函数来获取foreach循环中关联数组的下一个键.我尝试了一下,突然间它起了作用.(正如你在我的例子中看到的那样).

但为什么这个工作?是否有意义?......不是我!你能解释一下吗?

这是因为key(($array))部分但为什么?我的意思是..这是一个错误..我想写,key($array) …

php arrays behavior next

6
推荐指数
1
解决办法
999
查看次数

如何以编程方式删除我的NestedScrollView的布局行为?

我已经实现了消除layout_scrollFlags在我的CollapsingToolbarLayout.但我需要删除layout_behavior我的,NestedScrollView以便当我的嵌套滚动视图中没有内容时,工具栏的折叠也将被禁用.删除我的NestedScrollView的layout_behavior非常简单,我只是逐字地删除xml中的代码行,但是如何以编程方式删除它?

我的xml:

<android.support.design.widget.CoordinatorLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"

            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <android.support.design.widget.AppBarLayout
                android:id="@+id/appbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true"
                android:background="@android:color/white">

                <android.support.design.widget.CollapsingToolbarLayout
                    android:id="@+id/collapsing_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fitsSystemWindows="true"
                    app:contentScrim="?attr/colorPrimary"
                    app:layout_scrollFlags="scroll|exitUntilCollapsed">

                    <fragment
                        android:id="@+id/pawfile_header"
                        android:name="com.lightbulb.pawesome.fragments.PawfileHeaderFragment"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:layout_marginTop="10dp"
                        android:fitsSystemWindows="true"
                        app:layout_collapseMode="parallax" />

                </android.support.design.widget.CollapsingToolbarLayout>

            </android.support.design.widget.AppBarLayout>

            <fragment
                android:id="@+id/pawfile_timeline"
                android:name="com.lightbulb.pawesome.user_timeline.PawesomeUserTimelineFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior" />

        </android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

layout android scroll behavior android-collapsingtoolbarlayout

6
推荐指数
1
解决办法
5940
查看次数