Mysql 在数据库中扩展之前更新文件名
在我们的CRM上执行操作时,会触发一个流程。我想要的是,当它满足某些条件时,我需要更新数据库中文档的名称。但是,如果调用文档,例如:Mysql 在数据库中扩展之前更新文件名,mysql,sql,Mysql,Sql,在我们的CRM上执行操作时,会触发一个流程。我想要的是,当它满足某些条件时,我需要更新数据库中文档的名称。但是,如果调用文档,例如: Prospectus.docx 我想重命名该文档:products_1.docx 如何更新以在文档扩展名之前添加数字 $sql = "UPDATE b_bp_history SET NAME ='$documentName_[this is where I need the number before the document extension] ' WHE
Prospectus.docx
我想重命名该文档:products_1.docx
如何更新以在文档扩展名之前添加数字
$sql = "UPDATE b_bp_history SET NAME ='$documentName_[this is where I need the number before the document extension] '
WHERE ID='".$_POST['ID']."
我想我可能需要先剥离文档扩展,然后再添加它
我将原始文档名存储为$documentName
非常感谢您的帮助。以下是如何使用PHP函数生成新文档名(
$newDocumentName
)$documentName
和$number
:
$newDocumentName = preg_replace('/(.*)\.(.*)/', '$1_' . $number . '.$2', $documentName);
然后在UPDATE
SQL语句的SET
子句中使用$newDocumentName
,如下所示:
$sql = "UPDATE b_bp_history SET NAME ='$newDocumentName' WHERE ID='".$_POST['ID']."
从你称之为“更新状态”的地方,我的意思是,您可以对生成文件名进行单独的处理,并将其作为变量发送,以简单地更新语句。