老师 怎么连接mysql啊
<?php
// 本类由系统自动生成,仅供测
namespace Index\Controller;
use Ihink\Controller;
class IndexAction extends Action {
public function index(){
//echo C('name'),'<br/>';
//echo C('sex'),'<br/>';
//echo C('URL_MODEL'),'<br/>';
//U('模块/方法',array('id'=>1),xxxx)
//echo U('index/user',array('id'=>1),'html',false,'localhost:84');
//show();
//show();
//show();
//show();
//$arr=array(1,2,3,4,5,);
//dump($arr);
//$name='小炮';
//$this->name2=$name
//$this->assign('name',$name);
//$this->display();
//$me['name']='benge';
//$me['age']='18';
//$me['sex']='man';
//$this->assign('me',$me);
//$name='xiaohuang';
//$this->assign(name,$name);
$this->show('phpinfo();<br>');
$this->show('function index()<br>');
$this->display();
}
public function abc(){
//echo 'id is:'.$_GET['id'].'<br/>';
// echo '这里是index模块的user方法';
//$user=new Model('user');
//$data=$user->select();
//dump($data);
//$this->display();
$this->show('abc;<br>');
$User = M("user")->Select();
echo 'userName: '.$User[0]['userName'];
}
}
?>
<?php
return array(
//'配置项'=>'配置值'
//'URL_CASE_INSENSITIVE' =>true,//URL静态后缀设置
//'name'=>'Donsen1',
//'LOAD_EXT_CONFIG'=>'user',
//'URL_MODEL'=>1,
//'URL_HTML_SUFFIX' =>'shtml|html|xml',
'DB_TYPE' => 'mysql',
'DB_HOST' => 'localhost',
'DB_NAME' => 'muke',
'DB_USER' => 'root',
'DB_PWD' => '123456',
'DB_PORT' => '3306',
'DB_PREFIX' => 'mk',
//'DB_DEPLOY_TYPE' => 1,
//'DB_RW_SEPARATE' => ture,
);
?>
http://localhost:84/ThinkPHP/index.php/Index/abc
abc;
:(
php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。
閿欒浣嶇疆
FILE: C:\wamp\www\ThinkPHP\ThinkPHP\Lib\Driver\Db\DbMysql.class.php LINE: 58
ThinkPHP3.1.3 { Fast & Simple OOP PHP Framework } -- [ WE CAN DO IT JUST THI