小编Rey*_*rPM的帖子

使用php和MWS检索库存

我需要创建一个PHP脚本,从亚马逊检索和更新我的库存到我的个人网页.这可以用MWS或任何WS完成吗?并且还需要在我的网站前面显示我在亚马逊的所有产品,并显示用户通过亚马逊购买此项目的链接.

有帮助吗?

欢呼和许多提前感谢

php inventory amazon-web-services amazon-mws

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

Doctrine映射和PostgreSQL模式

我有两个Symfony应用程序映射到相同的PgSQL数据库.两个应用程序都使用FOSUserBundle,所以我试图处理不同模式的用户.阅读并对Google进行一些研究我按照以下方式构建我的实体:

/**
 * @ORM\Entity
 * @ORM\Table(name="internal_users", schema="internal")
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
 */
class InternalUser extends BaseUser
{
    ...
}
Run Code Online (Sandbox Code Playgroud)

然后我从Symofny2 shell尝试了以下内容:

Symfony > doctrine:schema:validate
[Mapping]  OK - The mapping files are correct.
[Database] FAIL - The database schema is not in sync with the current mapping file.
The command terminated with an error status (2)
Symfony > doctrine:schema:update --force
Updating database schema...
Database schema updated successfully! "14" queries were executed
Symfony >
Run Code Online (Sandbox Code Playgroud)

但是表格是在public架构上生成的,而不是internal我想要的架构,我做错了什么?有什么方法可以在不同的模式中创建表吗?

php postgresql database-schema symfony doctrine-orm

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

如何从应用了 Select2 的选择元素中删除选项?

所以,我有这个 HTML 代码:

<input type="checkbox" id="orders_lives_in_ccs" name="orders[lives_in_ccs]" class="lives_in_ccs">
<select id="orders_shipping_from" name="orders[shipping_from]" required="required" class="shipping_from toSelect2">
    <option value="" selected="selected">-- SELECCIONAR --</option>
    <option value="MRW">MRW - COBRO EN DESTINO</option>
    <option value="DOMESA">DOMESA - COBRO EN DESTINO</option>
    <option value="ZOOM">GRUPO ZOOM - COBRO EN DESTINO</option>
</select>
Run Code Online (Sandbox Code Playgroud)

我需要MRW.lives_in_ccs选中复选框时删除该选项,因此我编写了以下代码:

$(function () {
    $('.toSelect2').select2();

    var detachedMember;
    $('.lives_in_ccs').click(function () {
        if (this.checked) {
            detachedMember = $('.shipping_from option[value="MRW"]').detach();
        } else {
            $('.shipping_from option[value=""]').after(detachedMember);
        }

        $(".secure_shipping").toggle(this.checked);
    });
});
Run Code Online (Sandbox Code Playgroud)

该代码有效,但我遇到了问题并且没有找到解决方法。让这个jsFiddle 做这个测试:

  • 将 SELECT 保留为默认值,并--SELECCIONAR--在左侧标记复选标记,这将起作用并将MRW从主 …

javascript jquery jquery-select2

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

在foreach循环内部或外部调用flush()之间的区别,使用哪一个?

我有一段时间怀疑,但现在是时候问一下了.请参阅下面的代码并包含大量项目$someVar,例如200项:

// First approach
foreach($someVar as $item) {
    $item = $em->getRepository('someEntity')->find($item['value']);
    $em->remove($item);
    $em->flush();
}

// Second approach
foreach($someVar as $item) {
    $item = $em->getRepository('someEntity')->find($item['value']);
    $em->remove($item);
}

$em->flush();
Run Code Online (Sandbox Code Playgroud)
  • 这两个电话都会这样做吗?意味着从DB中删除记录?
  • 在性能水平,哪一个最好用?(学说有时表现为记忆杀手)
  • 如果两种方法都很好,我也可以使用相同的UPDATE查询吗?
  • 如果由于某种原因任何查询失败,我怎么抓到哪一个?可能是Doctrine给出的错误

用真实案例进行测试

在答案中提供了很好的信息,我仍然怀疑.看看这段代码:

foreach ($request->request->get( 'items' ) as $item) {
    $items = $em->getRepository( 'AppBundle:FacturaProductoSolicitud' )->find( $item['value'] );

    try {
        $em->remove( $items );
        $em->flush();

        array_push($itemsRemoved, $item['value']);
        $response['itemsRemoved'] = $itemsRemoved;
        $response['success'] = true;
    } catch ( \Exception $e ) {
        dump( $e->getMessage() );

        array_push($itemsNonRemoved, $item['value']);
        $response['itemsNonRemoved'] = $itemsNonRemoved;
        $response['success'] = …
Run Code Online (Sandbox Code Playgroud)

php symfony doctrine-orm

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

由于错误而无法删除图像:"来自守护程序的错误响应:引用不存在"

我在尝试清除Docker创建的图像时遇到了一个奇怪的问题.这就是我做的:

docker docker-image docker-container docker-cleanup

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

从同一个docker-compose文件构建时的随机容器名称

我有以下docker-compose.yml文件:

version: '2'
services:
    php-apache:
        image: reynierpm/php55-dev
        ports:
            - "80:80"
        environment:
            PHP_ERROR_REPORTING: 'E_ALL & ~E_DEPRECATED & ~E_NOTICE'
        volumes:
            - ~/data:/data
Run Code Online (Sandbox Code Playgroud)

每次运行以下命令时,docker-compose up -d它都会一直创建一个具有相同名称的容器,例如php55devwork_php-apache_1,该文件所在的文件夹加上服务名称.例如:

[rperez@dev php55-dev-work] $ tree
.
??? composer.json
??? docker-compose.yml
??? Dockerfile
Run Code Online (Sandbox Code Playgroud)

有没有办法随机更改此名称?现在我想在同一个容器中测试另一个应用程序但是另一个实例,我唯一的解决方案就是将内容复制到另一个文件夹中.

什么是最好的解决方案?

docker docker-compose

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

如何在不需要任何PHP脚本的情况下运行PHP-CLI容器?

我一直在尝试使用Docker和Docker Compose构建一个PHP cli容器,我想让它保持活着而不需要在其中运行任何PHP脚本.

我试过自己的Dockerfile:

FROM ubuntu:16.04
ENV PATH="/root/.composer/vendor/bin:${PATH}"

RUN apt-get update && \
    apt-get -y -qq install software-properties-common \
    xvfb \
    locales && \
    locale-gen en_US.UTF-8 && \
    export LC_ALL=en_US.UTF-8 && \
    export LANG=en_US.UTF-8 && \
    add-apt-repository ppa:ondrej/php && \
    apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated install \
    php7.1-curl \
    php7.1-cli \
    php7.1-bcmath \
    php7.1-json \
    php7.1-intl \
    php7.1-mbstring \
    php7.1-mcrypt \
    php7.1-mysql \
    php7.1-xml \
    php7.1-xsl \
    php7.1-zip \
    curl \
    git \
    wget \ …
Run Code Online (Sandbox Code Playgroud)

php docker docker-compose

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

How to overwrite some PHP defaults configuration?

Let's said that I have installed PHP 5.5.x in Ubuntu and it comes with a default configuration. I would like to overwrite a few configurations but I do not want to (this is how I know it's possible):

  • edit the default php.ini file
  • use a PHP block in each .php file to overwrite them
  • use .htaccess files and directives

I would like to create a file named custom-php.ini with the following lines (as an example):

; Basic configuration override
expose_php …
Run Code Online (Sandbox Code Playgroud)

php linux configuration php-5.5

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

Docker 卷选项以“root”用户身份创建文件夹

我以rperez. 我已经设置了 Docker 以便能够通过这个用户运行,所以我正在运行一个容器,如下所示:

$ docker run -d \
             -it \
             -e HOST_IP=192.168.1.66 \
             -e PHP_ERROR_REPORTING='E_ALL & ~E_STRICT' \
             -p 80:80 \
             -v ~/var/www:/var/www \
             --name php55-dev reypm/php55-dev
Run Code Online (Sandbox Code Playgroud)

请注意该$符号表示我以非 root 用户身份运行命令(使用#)。上面的命令创建以下目录:/home/rperez/var/www但所有者设置为root我相信这是因为dockerroot后台以用户身份运行。

有了这个设置,我无法在下面创建文件~/var/wwwrperez因为所有者是root如此......

处理这个问题的正确方法是什么?我已经阅读了这个这个,但不是很有帮助。

有什么帮助吗?

linux docker docker-volume docker-container

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

如何计算删除时的元素,这样我最终得不到空()?

我有以下代码:

<ul class="ul" id="selected_conditions">
  <li data-field="asset_locations_name" data-condition="in">
    <i class="fa fa-minus-circle delete_condition" aria-hidden="true" title="Click to remove this condition from the list"></i> WHERE asset_locations_name IN(
    <span class="condition_item" data-id="1213381233">
    <i class="fa fa-minus-circle delete" title="Click to remove this item from the list" aria-hidden="true"></i> 1213381233
    </span>,
    <span class="condition_item" data-id="1212371897">
    <i class="fa fa-minus-circle delete" title="Click to remove this item from the list" aria-hidden="true"></i> 1212371897
    </span> )
  </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

每次我点击小图标.delete我应该删除当前值,我可以使用以下代码实现:

$(function() {
  $('#selected_conditions').on('click', '.delete', function(ev) {
    var item_id = $(this).parent().data('id');
    $('.condition_item[data-id="'+ item_id +'"]').remove();
  });
}); …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

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