KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Mysqli bind_param() expected to be a reference, value given #1489

Open APS opened this topic on on Jun 18, 2020 - 11 comments

APS commented on Jun 18, 2020

Hi, I've got this error in the response when i try to type a search string on Datatables with Serverside.

DataTables::create(array(
...
"options"=>array(
		 "paging"=>true,
		 "pageLength" => 25,
		 "searching"=>true,
),
"method"=>'post',
"showFooter"=>true,
"serverSide"=>true,
...

Can you help me ? Thanks

KoolReport commented on Jun 19, 2020

Could you please send us more code. Especially the code related to serverSide setup like query.

APS commented on Jun 19, 2020

It's a very simple query :

DataTables::create(array(
	'name' => 'departements',
	'dataSource' => function() {
		return $this->src('geodata')
		->query("SELECT code, name FROM departements ORDER BY name");
	},

Thanks,

APS commented on Jun 24, 2020

Up,

And a precision about the error : "Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given" on line 340 of .../koolreport/core/src/datasources/MySQLDataSource.php

Thanks

David Winterburn commented on Jun 24, 2020

We will test this and check if this is a bug with MySQLDataSource. In the meantime you could try to use PDODataSource to see if it works for you. Thanks!

APS commented on Jun 24, 2020

It works with PDODataSource...

David Winterburn commented on Jun 25, 2020

Would you mind telling us which version of PHP your web server is using as well? Thanks!

David Winterburn commented on Jun 25, 2020

In another test, please open the file koolreport/core/src/datasource/MySQLDataSource.php and replace the following line:

    call_user_func_array(array($stmt, 'bind_param'), [$typeStr] + $params);

with this:

    $stmt->bind_param($typeStr, ...array_values($params)); //spread operator ... only available since PHP 5.6

Then try DataTables' serverSide with MySQLDataSource again. Thanks!

APS commented on Jun 25, 2020

PHP Version : 7.2

Ok, i will try to replace the line... Will you fix this in the next release ?

Thanks

David Winterburn commented on Jun 25, 2020

On our test server using PHP 7.2 we haven't been able to replicate your error so it's a difficult problem to know where it went wrong in the first place. Let us know if my previous post fixes your problem. Thanks!

APS commented on Jul 10, 2020

Hi,

Yes, this modification works : $stmt->bind_param($typeStr, ...array_values($params));

May be you could add a php version test on your next release...

Thanks

David Winterburn commented on Jul 10, 2020

Hi,

Would you please test the following replacements in MySQLDataSource.php and let us know the result. Replace:

call_user_func_array(array($stmt, 'bind_param'), [$typeStr] + $params);

with 1:

call_user_func_array(array($stmt, 'bind_param'), array_merge([$typeStr], $params));

or 2:

call_user_func_array(array($stmt, 'bind_param'), array_merge([$typeStr], array_values($params)));

Thanks!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None