tommyknocker / pdo-database-class

PHP PDO Wrapper which utilizes PDO and prepared statements
GNU Lesser General Public License v3.0
69 stars 46 forks source link

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 #10

Closed parto254 closed 2 years ago

parto254 commented 4 years ago

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

bas-surlinio commented 4 years ago

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

Phenomite commented 4 years ago

@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).\'`) ';
bas-surlinio commented 4 years ago

Correct

borakayalar commented 3 years ago
        //if (isset($dataColumns[0])) $this->query .= ' (`'.implode($dataColumns, '`, `').'`) ';
        if (isset($dataColumns[0])) $this->query .= ' (`' . implode('`, `', $dataColumns) . '`) ';
gvlasov commented 2 years ago

Will there be a release with this change?

tommyknocker commented 2 years ago

Yeah, sure. Releazed v1.1.1 today