问题列表 - 第29054页

将PostgreSQL数组转换为PHP数组

我在PHP中阅读Postgresql数组时遇到问题.我尝试过explode(),但这打破了包含字符串逗号的数组和str_getcsv(),但它也没有用,因为PostgreSQL没有引用日语字符串.

不工作:

explode(',', trim($pgArray['key'], '{}'));
str_getcsv( trim($pgArray['key'], '{}') );
Run Code Online (Sandbox Code Playgroud)

例:

// print_r() on PostgreSQL returned data: Array ( [strings] => {???, "some string without a comma", "a string, with a comma"} )

// Output: Array ( [0] => ??? [1] => "some string without a comma" [2] => "a string [3] => with a comma" ) 
explode(',', trim($pgArray['strings'], '{}'));

// Output: Array ( [0] => [1] => some string without a comma [2] => a string, with a comma ) …
Run Code Online (Sandbox Code Playgroud)

php arrays postgresql

32
推荐指数
3
解决办法
3万
查看次数

oracle上的Hibernate序列,@ GeneratedValue(strategy = GenerationType.AUTO)

我使用@GeneratedValue(strategy = GenerationType.AUTO)来生成我的实体上的ID.

我现在不知道它是如何工作的,但是在我的子表上,生成跟随父序列的ID值.

//parent table
@Entity
@Table (name = "parent")
public class Parent {

    @Id
    @GeneratedValue (strategy = GenerationType.AUTO)
    @Column (name = "id")
    private long id;


    @OneToMany (cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
    @JoinColumn (name = "parentId")
    @ForeignKey (name = "FKparent")
    private List<child> child;

}

//child table
@Entity
@Table (name = "child")
public class Child {

    @Id
    @GeneratedValue (strategy = GenerationType.AUTO)
    @Column (name = "id")
    private long id;
}
Run Code Online (Sandbox Code Playgroud)

父项上插入的ID值会更新序列.在child上插入ID值,更新序列.在下一个父项插入时,序列...使用由子插入更新的值...

这个Annotations,不是创建两个序列,只有一个.这是正确/预期的吗?

我只使用我的DAO服务插入我的实体 entityManager.persist(parent);

java oracle orm hibernate

20
推荐指数
2
解决办法
7万
查看次数

Scala方法,其中第二个参数的类型等于第一个参数的泛型类型的一部分

我想在Scala中创建一个特定的泛型方法.它需要两个参数.第一种是通用Java接口的类型(它来自JPA条件查询).它目前看起来像这样:

def genericFind(attribute:SingularAttribute[Person, _], value:Object) {
  ...
}

// The Java Interface which is the type of the first parameter in my find-method:
public interface SingularAttribute<X, T> extends Attribute<X, T>, Bindable<T>
Run Code Online (Sandbox Code Playgroud)

现在我想实现以下目的: value当前是java.lang.Object类型.但我想让它更具体.值必须与第一个参数中的占位符"_"具有相同的类型(因此代表Java接口中的"T").

这是不可能的,怎么样?

BTW对不起这个愚蠢的问题标题(有什么建议吗?)

编辑: 添加了一个可以使问题更清晰的附加示例:

// A practical example how the Scala method could be called 

// Java class:
public class Person_ {
  public static volatile SingularAttribute<Person, Long> id;
}

// Calling the method from Scala:
genericFind(Person_.id, Long)
Run Code Online (Sandbox Code Playgroud)

generics scala scala-2.8

5
推荐指数
1
解决办法
378
查看次数

使用C#在表单中动画Gif

在我的项目中,每当执行一个漫长的过程时,会显示一个带有小动画gif文件的小表单.我使用this.Show()打开表单和this.Close()来关闭表单.以下是我使用的代码.

public partial class PlzWaitMessage : Form
{
   public PlzWaitMessage()
   {
      InitializeComponent();
   }

   public void ShowSpalshSceen()
   {
      this.Show();
      Application.DoEvents();
   }

   public void CloseSpalshScreen()
   {
      this.Close();
   }
}
Run Code Online (Sandbox Code Playgroud)

表单打开时,图像文件不会立即开始动画.当它进行动画处理时,该过程通常是完整的或非常接近完成,这使得动画无用.加载表单后,有没有办法让gif动画?

c#

5
推荐指数
1
解决办法
6822
查看次数

如何发现pac中使用的de proxy

在FireFox中,互联网连接是通过代理自动配置文件"something.pac"进行的

我如何知道某个URL正在使用哪个代理服务器?

谢谢.

firefox proxy

8
推荐指数
2
解决办法
2万
查看次数

如何使用空值索引日期列?

当某些行具有空值时,我应该如何索引日期列?我们必须在日期范围和具有空日期的行之间选择行.

我们使用Oracle 9.2及更高版本.

我找到的选项

  1. 在日期列上使用位图索引
  2. 使用日期列上的索引和状态字段上的索引,当日期为空时,该值为1
  3. 使用日期列上的索引和其他已授予的非空列

我对选项的看法是:

到1:表必须使用许多不同的值才能使用位图索引
2:我必须仅为此目的添加一个字段,并在我想要将空日期行检索
为3 时更改查询:锁定棘手以添加字段到一个不是真正需要的索引

这种情况的最佳做法是什么?提前致谢

我读过的一些信息:

Oracle Date Index
Oracle什么时候索引空列值?

编辑

我们的表有300,000条记录.每天插入1,000到10,000条记录并删除.280,000条记录的deliver_at日期为null.它是一种挑选缓冲区.

我们的结构(翻译成英文)是:

create table orders
(
  orderid              VARCHAR2(6) not null,
  customerid           VARCHAR2(6) not null,
  compartment          VARCHAR2(8),
  externalstorage      NUMBER(1) default 0 not null,
  created_at           DATE not null,
  last_update          DATE not null,
  latest_delivery      DATE not null,
  delivered_at         DATE,
  delivery_group       VARCHAR2(9),
  fast_order           NUMBER(1) default 0 not null,
  order_type           NUMBER(1) default 0 not null,
  produkt_group        VARCHAR2(30)
)
Run Code Online (Sandbox Code Playgroud)

oracle indexing optimization null

13
推荐指数
3
解决办法
1万
查看次数

无法使用GetManifestResourceStream()加载清单资源

我已经使用XSD创建了自定义配置部分.为了解析这个新模式之后的配置文件,我加载了资源(我的.xsd文件):

public partial class MonitoringConfiguration
    {
        public const string ConfigXsd = "MonitoringAPI.Configuration.MonitoringConfiguration.xsd";
        public const string ConfigSchema = "urn:MonitoringConfiguration-1.0";

        private static XmlSchemaSet xmlSchemaSet;

        static MonitoringConfiguration()
        {
            xmlSchemaSet = new XmlSchemaSet();
            Stream xsdStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(ConfigXsd);
            XmlReader schemaReader = XmlReader.Create(xsdStream);
            xmlSchemaSet.Add(ConfigSchema, schemaReader);
        }

    }
Run Code Online (Sandbox Code Playgroud)

顺便说一下,我的资源是:MonitoringConfiguration.xsd.而另一个部分类的名称空间(表示.xsd文件背后的代码)是MonitoringAPI.Configuration.

问题出在这里:

 Stream xsdStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(ConfigXsd);
Run Code Online (Sandbox Code Playgroud)

xsdStream为null,所以我猜想无法找到资源!但为什么?

谢谢

.net c# configurationsection

47
推荐指数
5
解决办法
5万
查看次数

PHP会话超时

当用户登录时,我正在创建一个会话:

$_SESSION['id'] = $id;
Run Code Online (Sandbox Code Playgroud)

如何在X分钟的会话上指定超时,然后在达到X分钟后执行功能或页面重定向?

编辑:我忘了提到由于不活动我需要会话超时.

php session redirect timeout login

46
推荐指数
3
解决办法
23万
查看次数

Scala中的Trait,FunctionN或trait-inheriting-FunctionN?

我在Scala中有一个具有单一方法的特征.称之为Computable,单个方法是compute(input:Int):Int.我无法弄清楚我是否应该这样做

  • 使用单一方法将其保留为独立特征.
  • 继承自(Int => Int)并将"compute"重命名为"apply".
  • 只需摆脱Computable并使用(Int => Int).

支持它成为特征的一个因素是我可以有用地添加一些额外的方法.但是当然,如​​果它们都是根据计算方法实现的,那么我可以将它们分解为一个单独的对象.

支持仅使用函数类型的一个因素是简单性以及匿名函数的语法比匿名Computable实例的语法更简洁.但是,我无法区分实际上是Computable实例的对象与将Int映射到Int的其他函数,但不打算在与Computable相同的上下文中使用.

其他人如何处理这类问题?这里没有对错的答案; 我只是在寻求建议.

scala

8
推荐指数
2
解决办法
555
查看次数

在SQL Server中,如何为表创建引用变量?

我目前正在使用sp_executesql来执行带有动态表名的T-SQL语句.然而,看到类似的东西真是太丑了:

set @sql = 'UPDATE '+Table_Name+' SET ... WHERE '+someVar+' = ... AND '+someVar2' = ...'
sp_executesql @sql
Run Code Online (Sandbox Code Playgroud)

我更喜欢的是一个TABLE变量,它是对表的引用,所以我可以这样做:

UPDATE TableRef SET ... WHERE ...
Run Code Online (Sandbox Code Playgroud)

因为当我有很长的T-SQL语句时,由于字符串中的格式,它很难读取.

任何的意见都将会有帮助.

sql t-sql sql-server variables dynamic-sql

8
推荐指数
1
解决办法
5503
查看次数