LocoTrain
cn de en fr es it jp nl pt sv no
- 新闻 - 形象 - 目录 - 公司 + 更多

推进搜寻
高速缓存
形象
高速缓存

在这里是页的 LocoTrain 版本高速缓存 http://www.php.net/function.mysql-select-db April 12 2015 23:11:31.
La version « Cache » proposée par LocoTrain correspond au texte de la page lorsque le robot de LocoTrain l'a consultée.
En aucun cas LocoTrain est affilié au contenu textuel ci - dessous.

php: mysql_select_db - manual @import url("/styles/site.css"); @import url("/styles/mirror.css"); @import url("/styles/print.css"); downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net search for in the function list all php.net sites this mirror only online documentation bug database site news archive all changelogs just pear.php.net just pecl.php.net just talks.php.net general mailing list developer mailing list documentation mailing list php manual function reference mysql functions mysql_ affected_ rows mysql_ change_ user mysql_ client_ encoding mysql_ close mysql_ connect mysql_ create_ db mysql_ data_ seek mysql_ db_ name mysql_ db_ query mysql_ drop_ db mysql_ errno mysql_ error mysql_ escape_ string mysql_ fetch_ array mysql_ fetch_ assoc mysql_ fetch_ field mysql_ fetch_ lengths mysql_ fetch_ object mysql_ fetch_ row mysql_ field_ flags mysql_ field_ len mysql_ field_ name mysql_ field_ seek mysql_ field_ table mysql_ field_ type mysql_ free_ result mysql_ get_ client_ info mysql_ get_ host_ info mysql_ get_ proto_ info mysql_ get_ server_ info mysql_ info mysql_ insert_ id mysql_ list_ dbs mysql_ list_ fields mysql_ list_ processes mysql_ list_ tables mysql_ num_ fields mysql_ num_ rows mysql_ pconnect mysql_ ping mysql_ query mysql_ real_ escape_ string mysql_ result mysql_ select_ db mysql_ set_ charset mysql_ stat mysql_ tablename mysql_ thread_ id mysql_ unbuffered_ query mysql_set_charset mysql_result last updated: sun, 25 nov 2007 view this page in brazilian portuguese chinese (simplified) chinese (hong kong cantonese) chinese (traditional) czech danish dutch finnish french german greek hebrew hungarian italian japanese korean polish romanian russian slovak spanish swedish mysql_select_db (php 4, php 5, pecl mysql:1.0)mysql_select_db — select a mysql database description bool mysql_select_db ( string $database_name [, resource $link_identifier ] ) sets the current active database on the server that's associated with the specified link identifier. every subsequent call to mysql_query() will be made on the active database. parameters database_name the name of the database that is to be selected. link_identifier the mysql connection. if the link identifier is not specified, the last link opened by mysql_connect() is assumed. if no such link is found, it will try to create one as if mysql_connect() was called with no arguments. if by chance no connection is found or established, an e_warning level warning is generated. return values returns true on success or false on failure. examples example#1 mysql_select_db() example <?php$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');if (!$link) {    die('not connected : ' . mysql_error());}// make foo the current db$db_selected = mysql_select_db('foo', $link);if (!$db_selected) {    die ('can't use foo : ' . mysql_error());}?> notes note: for downward compatibility, the following deprecated alias may be used: mysql_selectdb() see also mysql_connect() mysql_pconnect() mysql_query() mysql_set_charset mysql_result last updated: sun, 25 nov 2007   add a note user contributed notes mysql_select_db me at khurshid dot com 09-sep-2007 08:03 problem with connecting to multiple databases within the same server is that every time you do: mysql_connect(host, username, passwd); it will reuse 'resource id' for every connection, which means you will end with only one connection reference to avoid that do: mysql_connect(host, username, passwd, true); keeps all connections separate. matsko at rogers dot com 10-may-2006 09:19 just incase the mysql_select_db() function still won't work with multiple database connections (as has happened to me before). $dbh1 = mysql_pconnect($host,$user,$pass); $dbh2 = mysql_pconnect($host,$user,$pass); you could do this... mysql_query("use database1",$dbh1); mysql_query("use database2",$dbh2); this does the same thing as the mysql_select_db() function... or this... you don't even have to select the database for each connection. mysql_query("select * from database1.table",$dbh1); mysql_query("select * from database2.table",$dbh2); maarten 19-aug-2005 02:09 previously posted comments about opening connections if the same parameters to mysql_connect() are used can be avoided by using the 'new_link' parameter to that function. this parameter has been available since php 4.2.0 and allows you to open a new link even if the call uses the same parameters. buzz at oska dot com 06-may-2005 02:39 as has been already commented, opening multiple connection handles with: <?php $connection_handle =  mysql_connect($hostname_and_port,$user,$password); ?> causes the connection id/handle to be reused if the exact same parameters are passed in to it.   this can be annoying if you want to work with multiple databases on the same server, but don't want to (a) use the database.table syntax in all your queries or (b) call the mysql_select_db($database) before every sql query just to be sure which database you are working with.     my solution is to create a handle for each database with mysql_connect (using ever so slightly different connection properties), and assign each of them to their own database permanently.  each time i do a mysql_query(...) call, i just include the connection handle that i want to do this call on eg (ive left out all error checking for simplicity sake): <?php // none of thesehandles are re-used as the connection parameters are different on them all, despite connecting to the same server (assuming 'myuser' and 'otheruser' have the same privileges/accesses in mysql) $handle_db1 = mysql_connect("localhost","myuser","apasswd"); $handle_db2 = mysql_connect("127.0.0.1","myuser","apasswd"); $handle_db3 = mysql_connect("localhost:3306","myuser","apasswd"); $handle_db4 = mysql_connect("localhost","otheruser","apasswd"); // give each handle it's own database to work with, permanently. mysql_select_db("db1",$handle_db1); mysql_select_db("db2",$handle_db2); mysql_select_db("db3",$handle_db3); mysql_select_db("db4",$handle_db4); //do a query from db1: $query = "select * from test"; $which = $handle_db1; mysql_query($query,$which); //do a query from db2 : $query = "select * from test"; $which = $handle_db2; mysql_query($query,$which); //etc ?> note that we didn't do a mysql_select_db between queries , and we didn't use the database name in the query either. of course, it has the overhead of setting up an extra connection.... but you may find this is preferable in some cases... dan ross 12-feb-2004 10:43 another way to select from 2 different databases on the same server: mysql_select_db("db1"); $res_db1 = mysql_query("select * from db1.foobar"); $res_db2 = mysql_query("select * from db2.foobar"); i.e. just prepend database name. james at gogo dot co dot nz 17-jan-2004 01:45 be carefull if you are using two databases on the same server at the same time.  by default mysql_connect returns the same connection id for multiple calls with the same server parameters, which means if you do <?php   $db1 = mysql_connect(...stuff...);   $db2 = mysql_connect(...stuff...);   mysql_select_db('db1', $db1);   mysql_select_db('db2', $db2); ?> then $db1 will actually have selected the database 'db2', because the second call to mysql_connect just returned the already opened connection id ! you have two options here, eiher you have to call mysql_select_db before each query you do, or if you're using php4.2+ there is a parameter to mysql_connect to force the creation of a new link. doug at xamo dot com 17-dec-2003 09:39 when you need to query data from multiple databases, note that mysql_select_db("db2")  doesn't prevent you from fetching more rows with result sets returned from "db1". mysql_select_db("db1"); $res_db1=mysql_query("select * from foobar"); myqsl_select_db("db2); $row_db1=mysql_fetch_object($res_db1); $res_db2=mysql_query("select * from test where id='$row_db1->id'"); add a note mysql_set_charset mysql_result last updated: sun, 25 nov 2007     show source | credits | sitemap | contact | advertising | mirror sites copyright © 2001-2008 the php group all rights reserved. this mirror generously provided by: webname last updated: tue feb 12 03:18:05 2008 cet
回到结果
LocoTrain (火 车) 是部分组Web Trains : 广告 - 宪章 - 版权 - 统计 - 新闻稿 - 电子邮件. 版权所有. All rights reserved.