dqhbuwrwq692118284
2012-04-23 00:47
浏览 39
已采纳

如何在codeigniter中引用数据库连接?

How can I call manually a PHP database function on CodeIgniter's database handler object? How to retrieve the connection ($dbc), or call a function like mysql_real_escape_string($dbc, $variable)?

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

如何在CodeIgniter的数据库处理程序对象上手动调用PHP数据库函数? 如何检索连接( $ dbc ),或调用类似 mysql_real_escape_string($ dbc,$ variable)的函数?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dongtanhe4607 2012-04-23 01:12
    已采纳

    You can call any mysql native function and access mysql connection id.

    See CodeIgniter User Guide

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • douchi2022 2014-01-10 12:19

    It is a better idea to use codeIgiter's functions: $this->db->escape() ,$this->db->escape_str() ,$this->db->escape_like_str()

    The function mysql_real_escape_string() is deprecated by now ( see: http://php.net/mysql_real_escape_string ).

    Instead use mysqli_real_escape_string or mysqli::real_escape_string (see for the syntax: http://www.php.net/manual/en/mysqli.real-escape-string.php)

    评论
    解决 无用
    打赏 举报
  • douwei7501 2016-09-29 17:50

    $this->db->conn_id will get you the current connection link object if you are in a CI context. It will return a mysqli or mysql link object that you can pass into functions like mysql_real_escape_string or the updated mysqli, which actually requires the link object. Source

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题