doupu7651 2013-10-02 10:06
浏览 211
已采纳

不区分大小写的自定义replace()函数

I'm attempting to do a batch replace on a database to translate british to american words. I've got a large array of words to replace, and also an array of various different tables to run through. I've come across the following thread that appears to provide exactly what I need, however I'm getting errors when trying it.

This is the error I'm encountering.

Exception caught: exception 'PDOException' with message
'SQLSTATE[HY000]: General error: 1436 Thread stack overrun:
10816 bytes used of a 131072 byte stack, and 128000 bytes needed.
Use 'mysqld -O thread_stack=#' to specify a bigger stack.' in /var/.../....php:303
Stack trace: #0 /var/.../....php(303): PDOStatement->execute(Array) #1 {main}

I'm using the custom defined MySQL function in this answer and generating a query that looks like this;

UPDATE field_data_body SET body_value = case_insensitive_replace(body_value, :british, :american)

I'm using the following to handle the PDO;

$query = $db->prepare($sql);
try {
    $query->execute($sql_fields_array);
} catch (PDOException $e) {
    echo "Exception caught: $e";
}

The $sql_fields_array array looks like this;

Array ( [british] => acclimatise [american] => acclimate )

I've tested changing the name of the custom function to make sure I created it correctly, and I did get an error saying the function name did not exist. So at least that part of what I've tried is correct.

Originally I was using the replace(lower(body_value), :british, :american) to do the search and replace, however this then changed everything to lowercase which is not what I want.

Any ideas with this error? Or if there's actually a better way I can automate this batch search and replace.

  • 写回答

2条回答 默认 最新

  • douye4051 2013-10-04 13:46
    关注

    The query appears to be working fine. After raising the thread stack from 128K to 256K the query successfully executed. It took a good 20-30 seconds mind you, but ran non the less.

    I've not noticed any adverse effects on the server after increasing this limit.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器