lazymofo / datagrid

PHP MySQL CRUD Datagrid
MIT License
141 stars 57 forks source link

group_concat limit override option suggestion #54

Closed sarangtc closed 4 years ago

sarangtc commented 4 years ago

sometimes large group_concats (useful for getting subquery data into a cell) fail due to mysql limits. This can be overridden, but would be nice to have an option in the class.

Just like you have public $charset_mysql = 'utf8mb4';

and then in the query function, you have:

        if(!$this->set_names){
            $sth = $this->dbh->prepare("set names $this->charset_mysql");
            $sth->execute();
            $this->set_names = true;
        }

You COULD also add a similar parameter: public $group_concat_max_len = '1000000'; or public $group_concat_max_len = ''; // leave blank for default, or 1000000 for large group_concats

and add this to the query function

        if(!$this->set_group_concat_max_len && !empty($this->group_concat_max_len)){
            $sth = $this->dbh->prepare("SET @@group_concat_max_len = $this->group_concat_max_len");
            $sth->execute();
            $this->set_group_concat_max_len = true;
        }
lazymofo commented 4 years ago

sarangtc,

i'll look at all these issues you posting soon. thanks! they all seem like valid issues i should address.

thanks, ian

On Fri, Jan 24, 2020 at 5:31 PM sarangtc notifications@github.com wrote:

sometimes large group_concats (useful for getting subquery data into a cell) fail due to mysql limits. This can be overridden, but would be nice to have an option in the class.

Just like you have public $charset_mysql = 'utf8mb4';

and then in the query function, you have:

    if(!$this->set_names){
        $sth = $this->dbh->prepare("set names $this->charset_mysql");
        $sth->execute();
        $this->set_names = true;
    }

You COULD also add a similar parameter: public $group_concat_max_len = '1000000'; or public $group_concat_max_len = ''; \ leave blank for default, or 1000000 for large group_concats

and add this to the query function

    if(!$this->set_group_concat_max_len && !empty($this->group_concat_max_len)){
        $sth = $this->dbh->prepare("SET @@group_concat_max_len = $this->group_concat_max_len");
        $sth->execute();
        $this->set_group_concat_max_len = true;
    }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lazymofo/datagrid/issues/54?email_source=notifications&email_token=ABRM2WBUAKH5JJ24JCLKKMDQ7OI73A5CNFSM4KLOGKHKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IIVALFQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRM2WDODKHWCMC6MOKDXODQ7OI73ANCNFSM4KLOGKHA .

lazymofo commented 4 years ago

I feel it's more straightforward to just write:

$lm->query("SET @@group_concat_max_len = 9999");

compared to:

$lm->group_concat_max_len = 9999;

I'm going to skip this feature for now.

On Fri, Jan 24, 2020 at 5:31 PM sarangtc notifications@github.com wrote:

sometimes large group_concats (useful for getting subquery data into a cell) fail due to mysql limits. This can be overridden, but would be nice to have an option in the class.

Just like you have public $charset_mysql = 'utf8mb4';

and then in the query function, you have:

    if(!$this->set_names){
        $sth = $this->dbh->prepare("set names $this->charset_mysql");
        $sth->execute();
        $this->set_names = true;
    }

You COULD also add a similar parameter: public $group_concat_max_len = '1000000'; or public $group_concat_max_len = ''; \ leave blank for default, or 1000000 for large group_concats

and add this to the query function

    if(!$this->set_group_concat_max_len && !empty($this->group_concat_max_len)){
        $sth = $this->dbh->prepare("SET @@group_concat_max_len = $this->group_concat_max_len");
        $sth->execute();
        $this->set_group_concat_max_len = true;
    }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lazymofo/datagrid/issues/54?email_source=notifications&email_token=ABRM2WBUAKH5JJ24JCLKKMDQ7OI73A5CNFSM4KLOGKHKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IIVALFQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRM2WDODKHWCMC6MOKDXODQ7OI73ANCNFSM4KLOGKHA .

sarangtc commented 4 years ago

understood