dph23577
2015-09-07 23:43
浏览 73
已采纳

在MySQL查询中使用PHP函数

Pretty much I have a function that converts a string to a URL friendly string.

Example: $string = "Hello World!", when passed through my function, it would read url($string) = "hello-world"

So what I want to do is find in my database where the row = "hello-world" But my databases aren't formatted like that so I want to pretty use my function is the sql query.

Example:

$sql = "SELECT * FROM table WHERE url(row) = 'hello-world'";

I don't know if this is possible or not. I know I could get the results use the function and then pass it though the database again. But I was hoping there was a simpler way.

By the way I am using MySQLi Procedural if it makes a difference.

图片转代码服务由CSDN问答提供 功能建议

我有一个将字符串转换为URL友好字符串的函数。

示例: $ string =“Hello World!”,当通过我的函数传递时,它会读取 url($ string)=“hello-world”

所以我想做的是在我的数据库中找到row =“hello-world” 但是我的数据库没有像那样格式化所以我想要很好地使用我的函数是sql 例如:

  $ sql =“SELECT * FROM table WHERE url(row)='hello-world'”;  
   
 
 

我不知道这是否可行。 我知道我可以使用该函数获得结果,然后再次通过数据库传递它。 但是我希望有一种更简单的方法。

顺便说一句,如果它有所作为,我使用的是MySQLi Procedural。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题