codeigniter 怎么获取mysql的版本号

codeigniter 怎么获取mysql的版本号,第1张

参考思路,用sql语句查询即可

支持标前缀

1)查询不等于且有等于

[php] view plain copy

$this->db->get_where('host',array('host'=>'ddd','id !='=>0))->row()

2)2表相交

[php] view plain copy

return $this->db

->select('f.*,count(s.id) as subtotal')

->from('category as f')->join('category s', 'f.id=s.upid', 'left')

->where('f.upid', $upid)

->group_by('f.id')

->order_by('f.sort', 'asc')

->get()->result()

3)多个order_by 排序

[php] view plain copy

return $this->db->select('*')

->from('v_category')

->where('upid',$upid)

->order_by('sort','asc')

->order_by('id','desc')

->get()->result()

4)单条记录

[php] view plain copy

return $this->db->get_where('category', array('id' =>$id))->row()

5)多条记录

[php] view plain copy

return $this->db->get_where('v_category', array('upid' =>$upid))->result()

6)统计个数

[php] view plain copy

$this->db->where('host',$host)->where('id !=',$id)->from('host')->count_all_results()

首先CodeIgniter连接数据库连不上,总是显示连接错误,但是又没有error信息,难以debug。

解决方案是:在application/config/database.php文件的最后加上这一段代码

复制代码

代码如下:

echo

'<pre>'

print_r($db['default'])

echo

'</pre>'

echo

'Trying

to

connect

to

database:

'

.$db['default']['database']

$dbh=mysql_connect

(

$db['default']['hostname'],

$db['default']['username'],

$db['default']['password'])

or

die('Cannot

connect

to

the

database

because:

'

.

mysql_error())

mysql_select_db

($db['default']['database'])

echo

'<br

/>

Connected

OK:'

die(

'file:

'

.__FILE__

.

'-->

Line:

'

.__LINE__)


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/8613896.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-18
下一篇 2023-04-18

发表评论

登录后才能评论

评论列表(0条)

保存