我正在尝试将我的Laravel 5.7项目连接到我们的iSeries数据库。我的运行环境是在 Linux 环境中运行的 Docker 中。每当我尝试对包含 NULL 值的表行执行 SELECT 时,都会收到以下错误:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967320 bytes)
将表中的 NULL 值替换为 '' 或其他任何值将按预期工作,所有值都正确返回。有问题的表只有 10 行数据。
我的控制器查询代码:
use AppNotification;
$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();
});
我的数据库.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 服务提供商。
我的 Docker文件:
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 内存限制不是一种选择。
感谢您的任何帮助。
假设您正在使用 PHP7.2,则尝试增加位于 php.ini
上的memory_limit
值,/etc/php/7.2/cli/php.ini
路径将包含您的 PHP 版本。您可以增加它,直到您的内存需求被填满(-1 表示无限(。但请记住,这不是一个好的做法。
不增加php.ini,它不会有帮助
当COL_WITH_NULL_VAL为空时,则 '' 否则COL_WITH_NULL_VAL结尾为 new_name,