pdo-database-class icon indicating copy to clipboard operation
pdo-database-class copied to clipboard

PHP 7.4 PHP Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in vendor/tommyknocker/pdo-database-class/PDODb.php on line 435

Open parto254 opened this issue 6 years ago • 6 comments

PHP 7.4 deprecated notice when inserting values using an array as the data source

The code:

$this->model->db->insert(
    'roles',
    [
        'role'=>'editor',
        'description'=>'Blog editor. Has access to blogs and blog posts.'
    ]
);

The error

PHP Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in vendor/tommyknocker/pdo-database-class/PDODb.php on line 435

parto254 avatar Jan 17 '20 15:01 parto254

Replace this line with: if (isset($dataColumns[0])) $this->query .= ' ('.implode(', ',$dataColumns).') ';

bas-surlinio avatar May 11 '20 05:05 bas-surlinio

@bas-surlinio

Replace this line with: if (isset($dataColumns[0])) $this->query .= ' ('.implode(', ',$dataColumns).') ';

As in this?

L435:

if (isset($dataColumns[0])) $this->query .= ' (`\'.implode(\'`, `\'$dataColumns).\'`) ';

Phenomite avatar May 19 '20 05:05 Phenomite

Correct

bas-surlinio avatar May 19 '20 09:05 bas-surlinio

        //if (isset($dataColumns[0])) $this->query .= ' (`'.implode($dataColumns, '`, `').'`) ';
        if (isset($dataColumns[0])) $this->query .= ' (`' . implode('`, `', $dataColumns) . '`) ';

borakayalar avatar Sep 18 '21 21:09 borakayalar

Will there be a release with this change?

gvlasov avatar Dec 19 '21 16:12 gvlasov

Yeah, sure. Releazed v1.1.1 today

tommyknocker avatar Dec 20 '21 03:12 tommyknocker