小编Lia*_*sby的帖子

PDO关闭连接

与MySQLi相比,PDO只是一个相当简单的问题.

使用MySQLi,要关闭连接,您可以执行以下操作:

$this->connection->close();
Run Code Online (Sandbox Code Playgroud)

但是对于PDO,它声明您使用以下命令打开连接:

$this->connection = new PDO();
Run Code Online (Sandbox Code Playgroud)

但要关闭您设置的连接null.

$this->connection = null;
Run Code Online (Sandbox Code Playgroud)

这是正确的,这实际上是否会释放PDO连接?(我知道它确实设置为null.)我的意思是MySQLi你必须调用一个函数(close)来关闭连接.PDO是否易于= null断开?或者是否有关闭连接的功能?

php pdo

107
推荐指数
4
解决办法
15万
查看次数

Symfony2 + Propel Collection未定义偏移量:2

我们使用propel和Symfony2形式创建了一个集合.我们可以毫无问题地保存表单,我们可以使用该集合添加第二个选项.如果我们然后保存然后尝试添加第3个集合,我们会收到以下错误:

Notice: Undefined offset: 2 
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪

in src/app/MyBundle/Model/om/BaseLabelsLabelsLinesMapsQuery.php at line 241  

$cton0 = $this->getNewCriterion(LabelsLabelsLinesMapsPeer::ID, $key[0], Criteria::EQUAL);
            $cton1 = $this->getNewCriterion(LabelsLabelsLinesMapsPeer::LABEL_ID, $key[1], Criteria::EQUAL);
            $cton0->addAnd($cton1);
            $cton2 = $this->getNewCriterion(LabelsLabelsLinesMapsPeer::LABEL_LINES_ID, $key[2], Criteria::EQUAL);
            $cton0->addAnd($cton2);
            $this->addOr($cton0);
        }
Run Code Online (Sandbox Code Playgroud)

我已经在下面发布了相关代码,但是由于存在大量代码.我们想知道是否有人遇到过同样的问题.

我已经发送了一个错误报告,其中包含不同的代码,这些代码产生了相同的错误但是我没有收到回复.错误报告在这里.

这是相关架构的片段:

<table name="labels_labels_lines_maps" isCrossRef="true">
    <column name="id"
            type="integer"
            required="true"
            autoIncrement="true"
            primaryKey="true"/>
    <column name="label_id"
            type="integer"
            primaryKey="true"/>
    <column name="label_lines_id"
            type="integer"
            primaryKey="true"/>
    <foreign-key foreignTable="labels" onDelete="cascade">
        <reference local="label_id" foreign="id"/>
    </foreign-key>
    <foreign-key foreignTable="labels_lines" onDelete="cascade">
        <reference local="label_lines_id" foreign="id"/>
    </foreign-key>
    <vendor type="mysql">
        <parameter name="Engine" value="InnoDB" />
        <parameter name="Charset" value="utf8" />
    </vendor>
</table>

<table name="labels_lines"> …
Run Code Online (Sandbox Code Playgroud)

php propel symfony

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

在xampp中添加Imagick

我已经按照以下步骤操作,http://bytehash.appspot.com/2012/02/Installing-imagick-for-php-in-windows-under-xampp我已经下载了想象力的dll文件,并将其添加到xampp/php/ext文件夹中并包含如下:extension=php_imagick_ts.dll.我还安装了imagemagick并且可以确认它已安装,因为我运行了以下命令:

C:\>convert -version
Version: ImageMagick 6.8.6-8 20
Copyright: Copyright (C) 1999-2
Features: DPC OpenMP
Delegates: bzlib djvu fftw font
ngo png ps tiff webp x xml zlib
Run Code Online (Sandbox Code Playgroud)

当我通过xampp控制面板重启apache时出现以下错误:

the procedure entry point php_checkuid_ex could not be located in the dynamic link library php5ts.dll
Run Code Online (Sandbox Code Playgroud)

并在以下错误消息后继续:

PHP Startup: Unable to load dynamic library "C:\xampp\php\ext\php_imagick_ts.dll" - The specified procedure could not be found
Run Code Online (Sandbox Code Playgroud)

如果在此消息之后我尝试复制并粘贴动态链接库位置 - C:\xampp\php\ext\php_imagick_ts.dll并将其粘贴到文档地址栏中,它会尝试打开文件

有没有人遇到这个错误?因为我在尝试安装msql3库或只是简单地取消注释php.ini文件中的一些其他扩展时遇到了同样的问题

任何建议都会很棒.谢谢

php apache xampp imagick php-extension

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

使用光栅PTR打印机在java中打印文件

我有两个使用java打印的代码,如下所示:

第一个准则

for(int i = 0; i < files.length; i++) {
    String file = "C:\\images\\colour\\"+files[i].getName();
    String filename = file;
    PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
    DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
    PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras);
    PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
    PrintService service = ServiceUI.printDialog(null, 200, 200, printService, defaultService, DocFlavor.INPUT_STREAM.GIF, pras);

    if (service != null) {
        DocPrintJob job = service.createPrintJob();

        PrintJobListener listener = new PrintJobAdapter() {
            public void printDataTransferCompleted(PrintJobEvent e) {
                System.exit(0);
            }
        };

        job.addPrintJobListener(listener);
        FileInputStream fis = new FileInputStream(filename);
        DocAttributeSet das = new …
Run Code Online (Sandbox Code Playgroud)

java pointers printdialog printers

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

Symfony2形式:货币货币符号和在树枝中显示

我在Symfony中有一个表单,它使用货币字段类型,货币设置为GBP.

当我将表单传递给twig时,表单将使用以下方式呈现:

{{ form_row(form.price) }}
Run Code Online (Sandbox Code Playgroud)

这将呈现以下html:

£<input id="app_product_price" name="app_product[price]" required="required" class="form-control" value="9.95" type="text">
Run Code Online (Sandbox Code Playgroud)

我的目标是尝试获取货币符号,以便我可以使用bootstrap money field:

<form class="form-inline">
  <div class="form-group">
    <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
    <div class="input-group">
      <div class="input-group-addon">$</div>
      <input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
      <div class="input-group-addon">.00</div>
    </div>
  </div>
  <button type="submit" class="btn btn-primary">Transfer cash</button>
</form>
Run Code Online (Sandbox Code Playgroud)

显然,我需要做一些样式.但是,我试图使用下面的货币符号,但似乎没有任何文件,我可以看到这样做.

{{ form_label(form.price) }}

{{ form_widget(form.price) }}
Run Code Online (Sandbox Code Playgroud)

这些似乎都无法获得货币,我也看了一下{{ form_widget(form.price.vars.currency) }}只显示错误的使用情况.

是否有任何已知的方法从表单字段中提取货币符号?或者我需要走Twig Form Theming的路线吗?

forms symfony twig

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

ZendFramework 2:设置date_default_timezone

我是Zend Framework 2的新手,想知道是否有一种设置日期默认时区的全局方式.

我知道我应该只能添加代码:

date_default_timezone_set("UTC");
Run Code Online (Sandbox Code Playgroud)

但是我一直在寻找大约一个小时,但找不到解决这个问题的答案.

我也试过在php.ini中设置它,但我不确定这是否会抑制错误消息.

提前致谢.

php date zend-framework2

2
推荐指数
1
解决办法
5524
查看次数

变量变量的使用不好的做法?

我刚刚读过这篇文章,在 php 中以以下方式使用变量是不好的做法吗?解释为什么它们不适合与类一起使用,但是,我必须创建要排序的动态变量

例如:

$array =
array(
 array("Line 1","Line 2","Line 3"),
 array("Line 1","Line 2","Line 3"),
 array("Line 1","Line 2","Line 3"),
)
$i = 1;
foreach($array as $item){
 $string = "Item".$i;
 $$string = $item[0]."some code".$item[1]."some code".$item[2]."some code";
}
Run Code Online (Sandbox Code Playgroud)

我知道每个辅助数组中只会有 3 个数组值,而且也只会有 3 个数组。

有没有办法使用“更好的实践”代码来实现这一目标?或者我忽略的更简单的方法?

感谢您提前抽出时间

php arrays variable-variables

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

Symfony2 动态图像使用资产

我最近刚刚从 SO 上的帖子中发现,不可能使用资产在树枝中渲染动态图像。所以我已经开始尝试使用asset命令添加动态图像。

目前,我尝试了以下方法:

{% for item in test %}
    <img src="{{ asset("../images/"item.thumbnail ) }} " alt="{{ item.alt }}" />
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

我也试过

{% for item in test %}
     <img src="{{ asset("../images/"{{item.thumbnail}} ) }} " alt="{{ item.alt }}" />
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

但不幸的是,这些都不会抛出任何错误,但它们也不返回任何内容。这甚至可能吗,如果有的话,有人能指出我正确的方向吗?

ps 我已经迭代了 item.thumbnail 的结果,并且还仔细检查了这些资产是否已安装到包中。此外,图像文件夹称为图像,而不是图像或 img。

先感谢您。

编辑:

对于所有想知道为什么我没有收到错误的人....我实际上是在错误的页面上,这就是为什么我可以看到任何错误。所以请注意,在发布之前检查您在正确的页面上是否没有错误。

php assets symfony twig

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

我有两个函数,我希望第二个函数在第一个函数完成后运行它的动画

function firstRun() {
   rightBox.style.animation = "TextEffectMadeWithCSS 10s";
}

function secondRun() {
   rightBox.style.animation = "TextEffectMadeWithCSS 10s";
}
Run Code Online (Sandbox Code Playgroud)

我不想使用Jquery,因为我是javascript的初学者.我不能在这个层次上理解大多数Jquery语法

javascript

0
推荐指数
1
解决办法
405
查看次数