Coder Social home page Coder Social logo

Comments (5)

onanying avatar onanying commented on June 8, 2024

当把连接赋值出来,延后析构,就可以了,这个bug非常奇怪,我在找swoole开发组的人一起看看。

$conn = $db->prepare('select * from users');
$result = $conn->queryAll();
$chan->push($result);

from mix.

liushzhql avatar liushzhql commented on June 8, 2024

当把连接赋值出来,延后析构,就可以了,这个bug非常奇怪,我在找swoole开发组的人一起看看。

$conn = $db->prepare('select * from users');
$result = $conn->queryAll();
$chan->push($result);

试了下确实如此,无论是mysql还是redis都需要将连接赋值出来,不然一但超过8个协程拿到连接就将channel销毁了,修复前只能暂时这样用了,thx~

from mix.

onanying avatar onanying commented on June 8, 2024

@liushzhql 已经解决了该问题,后面的版本发布 77b27a4 mix-php/mix-skeleton@6c7e6e9

from mix.

onanying avatar onanying commented on June 8, 2024

@liushzhql 搞定, https://github.com/mix-php/mix/releases/tag/v2.2.12

from mix.

liushzhql avatar liushzhql commented on June 8, 2024

mix-php/mix-skeleton v2.2.12中需要使用构造参数而非属性注入,示例如下:

/mix/manifest/beans/database.php

<?php

return [

    // Database
    [
        // 名称
        'name'            => 'database',
        // 作用域
        'scope'           => \Mix\Bean\BeanDefinition::SINGLETON,
        // 类路径
        'class'           => \Mix\Database\Database::class,
        // 构造函数注入
        'constructorArgs' => [
            // dsn
            getenv('DATABASE_DSN'),
            // username
            getenv('DATABASE_USERNAME'),
            // password
            getenv('DATABASE_PASSWORD'),
            // options: http://php.net/manual/zh/pdo.setattribute.php
            [
                // 设置默认的提取模式: \PDO::FETCH_OBJ | \PDO::FETCH_ASSOC
                \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
                // 超时
                \PDO::ATTR_TIMEOUT            => 5,
            ],
            //max opened connection
            getenv('POOL_MAX_OPEN'),
            //max idle connection
            getenv('POOL_MAX_IDLE'),
        ],
        // 属性注入
        'properties'      => [
            // 事件调度器
            'dispatcher' => ['ref' => 'eventDispatcher'],
        ],
    ],

];

from mix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.