-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limit on batches with prepared statements #49
Comments
Please, show me the queries in which an error occurs. |
This is a little example where this happens: $connection = new Database($nodes);
$connection->connect();
$connection->setKeyspace('tests');
$queryString = 'INSERT INTO test_table (tid, some_content) VALUES (:tid, :some_content)';
$connection->beginBatch();
for ($cont = 0; $cont < 100; $cont++) {
$uuid = getUUID();
$content = 'Random string with UUID: '.$uuid;
echo 'Cont: '.$cont.' UUID: '.$uuid."\n";
$connection->query($queryString, ['tid' => $uuid, 'some_content' => $content]);
}
$connection->applyBatch(); |
There is a problem with the appendQueryToStack function in Database.php. Replacing the POSTFIX_DUPLICATE_QUERY_VARIABLE by an counter should work: /**
* @var int
*/
private $key_index = 0;
private function appendQueryToStack($cql, array $values) {
$valuesModified = false;
foreach($values as $key => $value) {
if (is_string($key) && isset($this->batchQueryData[$key])) {
$newFieldName = $key . "_" . ++$this->key_index;
$cql = str_replace(":{$key}", ":{$newFieldName}", $cql);
unset($values[$key]);
$values[$newFieldName] = $value;
$valuesModified = true;
}
} |
Yes, that fixed the issue. Thanks guys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey,
I'm playing around with your driver double checking if it fits our needs and just found out that when doing batches with preparedstatements and with more than 95 statements PHP crashes with "PHP Fatal error: Maximum function nesting level", this is coming from the recursive call to appendQueryToStack. This is working fine with normal statements though.
Is there any way you can remove that recursion? I don't really like the idea of tune php configuration to support as many recursive calls as my biggest batch.
Thanks
The text was updated successfully, but these errors were encountered: