当所选行具有NULL值时,允许的内存大小耗尽

问题描述 投票:0回答:1

我正在尝试将我的Laravel 5.7项目连接到我们的iSeries数据库。我的运行环境是在Linux环境中运行的Docker中。每当我尝试对包含NULL值的表行执行SELECT时,我会收到以下错误:

Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967320 bytes)

使用''或其他任何内容替换表中的NULL值,按预期工作,并正确返回所有值。有问题的表只有10行数据。

我的Controller查询代码:

use App\Notification;
$notifications = Notification::where('user_id', '=', $currentUser)->orderBy('id', 'desc')->get();

我的桌子()迁移:

Schema::create('notifications', function (Blueprint $table) {
    $table->increments('id');
    $table->string('user_id');
    $table->string('type');
    $table->integer('severity');
    $table->text('message');
    $table->string('link')->nullable();
    $table->timestamp('read_at')->nullable();
    $table->timestamps();
    $table->softDeletes();
});

我的database.php连接数组:

'connections' => [
    'db2' => [
        'driver' => 'db2_ibmi_odbc',
        // or 'db2_ibmi_ibm' / 'db2_zos_odbc' / 'db2_expressc_odbc
        'driverName' => '{iSeries}',
        // or '{iSeries Access ODBC Driver}' / '{IBM i Access ODBC Driver 64-bit}' / '{IBM DB2 ODBC DRIVER}
        'host' => 'redacted',
        'username' => 'ROBERT',
        'password' => 'password',
        'database' => 'ROBERT',
        'prefix' => '',
        'schema' => 'ROBERT',
        'port' => 446,
        'date_format' => 'Y-m-d H:i:s.u',
        // or 'Y-m-d H:i:s.u' / 'Y-m-d-H.i.s.u'...
        'odbc_keywords' => [
            'SIGNON' => 3,
            'SSL' => 0,
            'CommitMode' => 2,
            'ConnectionType' => 0,
            'DefaultLibraries' => '',
            'Naming' => 0,
            'UNICODESQL' => 0,
            'DateFormat' => 5,
            'DateSeperator' => 0,
            'Decimal' => 0,
            'TimeFormat' => 0,
            'TimeSeparator' => 0,
            'TimestampFormat' => 0,
            'ConvertDateTimeToChar' => 0,
            'BLOCKFETCH' => 1,
            'BlockSizeKB' => 32,
            'AllowDataCompression' => 1,
            'CONCURRENCY' => 0,
            'LAZYCLOSE' => 0,
            'MaxFieldLength' => 15360,
            'PREFETCH' => 0,
            'QUERYTIMEOUT' => 1,
            'DefaultPkgLibrary' => 'QGPL',
            'DefaultPackage' => 'A /DEFAULT(IBM),2,0,1,0',
            'ExtendedDynamic' => 0,
            'QAQQINILibrary' => '',
            'SQDIAGCODE' => '',
            'LANGUAGEID' => 'ENU',
            'SORTTABLE' => '',
            'SortSequence' => 0,
            'SORTWEIGHT' => 0,
            'AllowUnsupportedChar' => 0,
            'CCSID' => 819,
            'GRAPHIC' => 0,
            'ForceTranslation' => 0,
            'ALLOWPROCCALLS' => 0,
            'DB2SQLSTATES' => 0,
            'DEBUG' => 0,
            'TRUEAUTOCOMMIT' => 0,
            'CATALOGOPTIONS' => 3,
            'LibraryView' => 0,
            'ODBCRemarks' => 0,
            'SEARCHPATTERN' => 1,
            'TranslationDLL' => '',
            'TranslationOption' => 0,
            'MAXTRACESIZE' => 0,
            'MultipleTraceFiles' => 1,
            'TRACE' => 0,
            'TRACEFILENAME' => '',
            'ExtendedColInfo' => 0,
        ],
        'options' => [
            PDO::ATTR_CASE => PDO::CASE_LOWER,
            PDO::ATTR_PERSISTENT => false,
            //PDO::I5_ATTR_DBC_SYS_NAMING => false,
            //PDO::I5_ATTR_COMMIT => PDO::I5_TXN_NO_COMMIT,
            //PDO::I5_ATTR_JOB_SORT => false,
            //PDO::I5_ATTR_DBC_LIBL => '',
            //PDO::I5_ATTR_DBC_CURLIB => '', 
        ]
    ],
........more, unused connections

我正在使用cooperl22 / laravel-db2服务提供商。

我的DockerFile:

FROM php:7.2-fpm-stretch

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /tmp

ADD php/www.conf /usr/local/etc/php-fpm.d/www.conf
ADD php/zz-docker.conf /usr/local/etc/php-fpm.d/zz-docker.conf
ADD os/freetds.conf /etc/freetds/freetds.conf
ADD os/ldap.conf /etc/ldap.conf 
ADD os/main.cf /etc/postfix/main.cf
ADD iseriesaccess_7.1.0-1.0_amd64.deb /

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y postfix git libssh2-1 libssh2-1-dev telnet autoconf unixodbc-dev \
unixodbc odbcinst freetds-bin freetds-dev tdsodbc ghostscript net-tools libldap2-dev zip unzip && \
pecl install ssh2-1.1.2

RUN ln -s /usr/local/bin/php /usr/bin/php
RUN ln -s /usr/lib/x86_64-linux-gnu /usr/lib64
RUN dpkg -i /iseriesaccess_7.1.0-1.0_amd64.deb

RUN docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr/ && \
docker-php-ext-install pdo_odbc pdo_mysql ldap

ADD os/odbc.ini /etc/odbc.ini
ADD os/odbcinst.ini /etc/odbcinst.ini

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

CMD ["php-fpm"]

EXPOSE 5000

如您所见,我正在使用iseriesaccess_7.1.0-1.0_amd64.deb驱动程序。

看看其他答案,提高php内存限制不是一个选择。

谢谢你的帮助。

php laravel docker odbc ibm-midrange
1个回答
0
投票

尝试在memory_limit上的php.ini文件中增加/etc/php/7.2/cli/php.ini的值,假设你正在使用PHP7.2,路径将包含你的php版本。你可以增加它直到你的内存需求满了(-1为无限)。但请记住,这不是一个好习惯。

© www.soinside.com 2019 - 2024. All rights reserved.