知识屋:更实用的电脑技术知识网站
所在位置:首页 > 编程技术  > PHP编程

CI框架连接数据库配置操作以及多数据库操作

发表时间:2014-09-05来源:网络

<strong style="color: rgb(50, 62, 50); font-family: simsun; font-size: 14px; line-height: 21px;">数据库快速入门例子代码</strong><p style="font-size: 14px; margin-top: 0px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(50, 62, 50); font-family: simsun;">下面的内容将简单说明怎样使用数据库。更详细的信息请阅读各个函数的单独介绍页面。<br /><br />初始化数据库类<br />下面的代码将依据你的数据库配置载入并初始化数据库类:<br /><br />$this-&gt;load-&gt;database();<br />&nbsp;<wbr /><br />一旦被载入,你可以在任何地方像这样使用它:<br /><br />注意: 如果你的所有页面均要求初始化数据库类,你可以让它自动加载。详见 数据库连接。<br /><br />多结果标准查询(对象形式)<br />$query = $this-&gt;db-&gt;query(&#39;SELECT name, title, email FROM my_table&#39;);<br /><br />foreach ($query-&gt;result() as $row)<br />{<br />&nbsp;<wbr />&nbsp;echo $row-&gt;title;<br />&nbsp;<wbr />&nbsp;echo $row-&gt;name;<br />&nbsp;<wbr />&nbsp;echo $row-&gt;email;<br />}<br /><br />echo &#39;Total Results: &#39; . $query-&gt;num_rows();&nbsp;<wbr /><br />上面的result()函数返回一个对象的数组。例如:$row-&gt;title<br /><br />多结果标准查询(数组形式)<br />$query = $this-&gt;db-&gt;query(&#39;SELECT name, title, email FROM my_table&#39;);<br /><br />foreach ($query-&gt;result_array() as $row)<br />{<br />&nbsp;<wbr />&nbsp;echo $row[&#39;title&#39;];<br />&nbsp;<wbr />&nbsp;echo $row[&#39;name&#39;];<br />&nbsp;<wbr />&nbsp;echo $row[&#39;email&#39;];<br />}<br />&nbsp;<wbr /><br />上面的result_array()函数返回一个带下标的数组。例如:$row[&#39;title&#39;]<br /><br />测试查询结果<br />如果你的查询可能不返回结果,我们建议你先使用 num_rows()函数来测试:<br /><br />$query = $this-&gt;db-&gt;query(&quot;YOUR QUERY&quot;);<br /><br />if ($query-&gt;num_rows() &gt; 0)<br />{<br />&nbsp;<wbr />&nbsp;foreach ($query-&gt;result() as $row)<br />&nbsp;<wbr />&nbsp;{<br />&nbsp;<wbr />&nbsp;echo $row-&gt;title;<br />&nbsp;<wbr />&nbsp;echo $row-&gt;name;<br />&nbsp;<wbr />&nbsp;echo $row-&gt;body;<br />&nbsp;<wbr />&nbsp;}<br />}&nbsp;<wbr /><br />单结果标准查询(对象形式)<br />$query = $this-&gt;db-&gt;query(&#39;SELECT name FROM my_table LIMIT 1&#39;);<br /><br />$row = $query-&gt;row();<br />echo $row-&gt;name;<br /><br />上面的row()函数返回一个 对象。例如:$row-&gt;name<br /><br />单结果标准查询(数组形式)<br />$query = $this-&gt;db-&gt;query(&#39;SELECT name FROM my_table LIMIT 1&#39;);<br /><br />$row = $query-&gt;row_array();<br />echo $row[&#39;name&#39;];<br /><br />上面的row_array()函数返回一个 数组。例如:$row[&#39;name&#39;]<br /><br />标准插入(insert)<br />$sql = &quot;INSERT INTO mytable (title, name)&nbsp;<wbr /><br />&nbsp;<wbr />&nbsp;VALUES (&quot;.$this-&gt;db-&gt;escape($title).&quot;, &quot;.$this-&gt;db-&gt;escape($name).&quot;)&quot;;<br /><br />$this-&gt;db-&gt;query($sql);<br /><br />echo $this-&gt;db-&gt;affected_rows();&nbsp;<wbr /><br />快捷查询<br />快捷查询类能为我们提供快速取得数据的途径:<br /><br />$query = $this-&gt;db-&gt;get(&#39;table_name&#39;);<br /><br />foreach ($query-&gt;result() as $row)<br />{<br />&nbsp;<wbr />&nbsp;echo $row-&gt;title;<br />}<br />&nbsp;<wbr /><br />上面的get()函数返回数据表中所有的结果。 快捷查询类 提供所有数据库操作的快捷函数。<br /><br />快捷插入(insert)<br />$data = array(<br />&nbsp;<wbr />&nbsp;&#39;title&#39; =&gt; $title,<br />&nbsp;<wbr />&nbsp;&#39;name&#39; =&gt; $name,<br />&nbsp;<wbr />&nbsp;&#39;date&#39; =&gt; $date<br />&nbsp;<wbr />&nbsp;);<br /><br />$this-&gt;db-&gt;insert(&#39;mytable&#39;, $data);&nbsp;<wbr /><br /><br />// Produces: INSERT INTO mytable (title, name, date) VALUES (&#39;{$title}&#39;, &#39;{$name}&#39;, &#39;{$date}&#39;)</p><p style="font-size: 14px; margin-top: 0px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(50, 62, 50); font-family: simsun;">数据库配置<br />CodeIgniter 有一个配置文件让你存放数据库连接值(username:用户名,password:密码,database name:数据库名,等等..). 配置文件位于以下路径:<br /><br />application/config/database.php<br /><br />配件文件存放在一个如下格式的一个多维数组里:<br /><br />$db[&#39;default&#39;][&#39;hostname&#39;] = &quot;localhost&quot;;<br />$db[&#39;default&#39;][&#39;username&#39;] = &quot;root&quot;;<br />$db[&#39;default&#39;][&#39;password&#39;] = &quot;&quot;;<br />$db[&#39;default&#39;][&#39;database&#39;] = &quot;database_name&quot;;<br />$db[&#39;default&#39;][&#39;dbdriver&#39;] = &quot;mysql&quot;;<br />$db[&#39;default&#39;][&#39;dbprefix&#39;] = &quot;&quot;;<br />$db[&#39;default&#39;][&#39;pconnect&#39;] = TRUE;<br />$db[&#39;default&#39;][&#39;db_debug&#39;] = FALSE;<br />$db[&#39;default&#39;][&#39;cache_on&#39;] = FALSE;<br />$db[&#39;default&#39;][&#39;cachedir&#39;] = &quot;&quot;;<br />$db[&#39;default&#39;][&#39;char_set&#39;] = &quot;utf8&quot;;<br />$db[&#39;default&#39;][&#39;dbcollat&#39;] = &quot;utf8_general_ci&quot;;<br />&nbsp;<wbr /><br />我们使用多维数组的原因是为了让你随意的存储多个连接值的设置。举例:如果你运行多个环境(development:开发、production:制作、test:测试 等等..),你能为每个环境建立独立的连接组,并在组直接进行切换。举例,设置一个&quot;test&quot;环境,你可以这样做:<br /><br />$db[&#39;test&#39;][&#39;hostname&#39;] = &quot;localhost&quot;;<br />$db[&#39;test&#39;][&#39;username&#39;] = &quot;root&quot;;<br />$db[&#39;test&#39;][&#39;password&#39;] = &quot;&quot;;<br />$db[&#39;test&#39;][&#39;database&#39;] = &quot;database_name&quot;;<br />$db[&#39;test&#39;][&#39;dbdriver&#39;] = &quot;mysql&quot;;<br />$db[&#39;test&#39;][&#39;dbprefix&#39;] = &quot;&quot;;<br />$db[&#39;test&#39;][&#39;pconnect&#39;] = TRUE;<br />$db[&#39;test&#39;][&#39;db_debug&#39;] = FALSE;<br />$db[&#39;test&#39;][&#39;cache_on&#39;] = FALSE;<br />$db[&#39;test&#39;][&#39;cachedir&#39;] = &quot;&quot;;<br />$db[&#39;test&#39;][&#39;char_set&#39;] = &quot;utf8&quot;;<br />$db[&#39;test&#39;][&#39;dbcollat&#39;] = &quot;utf8_general_ci&quot;;<br />&nbsp;<wbr /><br />那么,告诉系统使用&quot;test&quot;组,你可以设置位于配置文件中的变量:<br /><br />$active_group = &quot;test&quot;;<br />&nbsp;<wbr /><br />注意: &quot;test&quot;的名字是任意的,这可以让你自由设置,我们的主要连接默认使用&quot;default&quot;这个名字,当然,您可以基于您的项目为它起一个更有意义的名字。<br /><br />Active Record<br />Active Record 类 可以通过数据库配置文件里的$active_record变量进行全局的设定(允许/禁止 TRUE/FALSE (boolean)). 如果你不用这个类,哪么你可以通过将这个变量值设置成FALSE来减少在数据库类初始化时对电脑资源的消耗。<br /><br />$active_record = TRUE;<br />&nbsp;<wbr /><br />注意: 一些CodeIgniter的类,例如Sessions,在执行一些函数的时候需要Active Records的支持。<br /><br /><strong>参数解析</strong>:<br />hostname - 数据库的主机名,通常位于本机,可以表示为 &quot;localhost&quot;.&nbsp;<wbr /><br />username - 需要连接到数据库的用户名.&nbsp;<wbr /><br />password - 登陆数据库的密码.&nbsp;<wbr /><br />database - 你需要连接的数据库名.&nbsp;<wbr /><br />dbdriver - 数据库类型。如:mysql、postgres、odbc 等。必须为小写字母。&nbsp;<wbr /><br />dbprefix - 当运行Active Record查询时数据表的前缀,它允许在一个数据库上安装多个CodeIgniter程序.&nbsp;<wbr /><br />pconnect - TRUE/FALSE (boolean) - 使用持续连接.&nbsp;<wbr /><br />db_debug - TRUE/FALSE (boolean) - 显示数据库错误信息.&nbsp;<wbr /><br />cache_on - TRUE/FALSE (boolean) - 数据库查询缓存是否开启,详情请见数据库缓存类。&nbsp;<wbr /><br />cachedir - 数据库查询缓存目录所在的服务器绝对路径。&nbsp;<wbr /><br />char_set - 与数据库通信时所使用的字符集。&nbsp;<wbr /><br />dbcollat - 与数据库通信时所使用的字符规则(character collation )。&nbsp;<wbr /><br />port - 数据库端口号. 当前只用于 Postgres 驱动程序. 要使用这个值,你应该添加一行代码到数据库配置数组。<br />$db[&#39;default&#39;][&#39;port&#39;] = 5432;<br />&nbsp;<wbr /><br />提示: 并不是所有的值都是必须的,这取决与您所使用的数据库平台,如(MySQL, Postgres, 等.) 例如, 当你使用SQLite时,你不需要提供username 或 password, 数据库名字就是您数据库文件的路径. 以上内容假定您使用的是 MySQL 数据库.</p><p style="font-size: 14px; margin-top: 0px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(50, 62, 50); font-family: simsun;">&nbsp;<wbr /></p><p style="font-size: 14px; margin-top: 0px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(50, 62, 50); font-family: simsun;">连接你的数据库<br />有两种方法连接数据库:<br /><br /><strong>自动连接</strong><br />&ldquo;自动连接&rdquo; 功能将在每个一页面加载时被自动实例化数据库类。要启用&ldquo;自动连接&rdquo;,可在如下文件中的 library 数组里添加 database:<br /><br />application/config/autoload.php<br /><br /><strong>手动连接</strong><br />如果仅仅是一部分页面要求数据库连接,你可以在你有需要的函数里手工添加如下代码或者在你的类里手工添加以供该类使用。<br /><br />$this-&gt;load-&gt;database();<br />&nbsp;<wbr /><br />如果以上函数的第一个参数没有任何信息,它将会在系统指定的数据库配置文件中寻找,对多数人而言,这是一个首选的方法。<br /><br />可用的参数<br />数据库连接值,用数组或DSN字符串传递。&nbsp;<wbr /><br />TRUE/FALSE (boolean)。是否返回连接ID (参阅下面的&ldquo;连接多数据库&rdquo;)。&nbsp;<wbr /><br />TRUE/FALSE (boolean)。是否启用 Active Record 类。默认设置为 TRUE。&nbsp;<wbr /><br />手动连接到一个数据库<br />函数的第一个参数能够从你的配置文件中自由的指定你自定义的详细的数据库配置信息。或者你甚至可以不通过指定的配置文件来提交数据库的连接属性。样例:<br /><br />要从你的配置文件中选择一个指定的数组你可以这么做:<br /><br />$this-&gt;load-&gt;database(&#39;group_name&#39;);<br />&nbsp;<wbr /><br />group_name指的是存在于你的配置文件中的带有数据库连接信息的数组的名字。<br /><br />要手动连接你要求的数据库你可以通过定义以下数组来实现:<br /><br />$config[&#39;hostname&#39;] = &quot;localhost&quot;;<br />$config[&#39;username&#39;] = &quot;myusername&quot;;<br />$config[&#39;password&#39;] = &quot;mypassword&quot;;<br />$config[&#39;database&#39;] = &quot;mydatabase&quot;;<br />$config[&#39;dbdriver&#39;] = &quot;mysql&quot;;<br />$config[&#39;dbprefix&#39;] = &quot;&quot;;<br />$config[&#39;pconnect&#39;] = FALSE;<br />$config[&#39;db_debug&#39;] = TRUE;<br />$config[&#39;cache_on&#39;] = FALSE;<br />$config[&#39;cachedir&#39;] = &quot;&quot;;<br />$config[&#39;char_set&#39;] = &quot;utf8&quot;;<br />$config[&#39;dbcollat&#39;] = &quot;utf8_general_ci&quot;;<br /><br />$this-&gt;load-&gt;database($config);<br />&nbsp;<wbr /><br />想得到每一个配置属性的详细信息可点击 这里.<br /><br />或者你可以以DSN的方式提交数据库配置信息。 DSN必然通过以下方式实现:<br /><br />$dsn = &#39;dbdriver://username:password@hostname/database&#39;;<br /><br />$this-&gt;load-&gt;database($dsn);<br />&nbsp;<wbr /><br />当用 DSN 字符串连接时,要覆盖配置默认值,则添加配置变量为查询字符串。<br /><br />$dsn = &#39;dbdriver://username:password@hostname/database?char_set=utf8&amp;dbcollat=utf8_general_ci&amp;cache_on=true&amp;cachedir=/path/to/cache&#39;;<br /><br />$this-&gt;load-&gt;database($dsn);<br />&nbsp;<wbr /><br /><strong>连接多数据库</strong><br />如果你需要同时连接多于一个的数据库,你可以用以下方式来实现:<br /><br />$DB1 = $this-&gt;load-&gt;database(&#39;group_one&#39;, TRUE);<br />$DB2 = $this-&gt;load-&gt;database(&#39;group_two&#39;, TRUE);&nbsp;<wbr /><br />注意:改变 &quot;group_one&quot; 和 &quot;group_two&quot; 为你指定了连接属性的组名 (或者通过上边说过的连接数组的数组名)。<br /><br />通过设置函数的第二个参数为TRUE(boolean)来返回一个数据库对象。<br /><br />当你使用这种方法,你将用对象名来执行操作命令而不是用户向导模式,也就是说,你将用以下方式执行数据库操作:<br /><br />$DB1-&gt;query();<br />$DB1-&gt;result();<br />etc...<br /><br />而不是:<br /><br />$this-&gt;db-&gt;query();<br />$this-&gt;db-&gt;result();<br />etc...<br /><br />重新连接 / 保持连接有效<br />当你正在进行一些重量级的PHP操作(例如处理图片)时,如果超出了数据库服务器的空闲超时限度,你应该考虑在执行更多查询之前使用reconnect()方法来向服务器发送ping命令,这样可以优雅地保持或重新建立连接。<br /><br />$this-&gt;db-&gt;reconnect();</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);">CI中的数据库操作</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);">&nbsp;</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);">在system/application/config 文件夹和里面的config文件里已经配置了参数</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);">$active_group = &quot;default&quot;;<br />$db[&#39;default&#39;][&#39;hostname&#39;] = &quot;&quot;;&nbsp; hostname: 你的数据库的位置, 举例来说, &#39;localhost&#39; 或 IP 地址&nbsp;<br />$db[&#39;default&#39;][&#39;username&#39;] = &quot;&quot;;&nbsp; username和password: 使用者名称和密码必须有充分的权限,允许你的网站存取数据库中的数据。<br />$db[&#39;default&#39;][&#39;password&#39;] = &quot;&quot;;&nbsp;<br />$db[&#39;default&#39;][&#39;database&#39;] = &quot;&quot;;&nbsp; database: 你的数据库的名字, 举例来说, &#39;websits&#39;&nbsp;<br />$db[&#39;default&#39;][&#39;dbdriver&#39;] = &quot;&quot;;&nbsp; dbdriver: 你正在使用的数据库的类型 - CI可受的有选项有MySQL、MySQLi、 Postgre SQL、ODBC和MS SQL</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);">CI中第一次连接数据库,在控制器或模型的构造函数里输入以下语句<br />$this-&gt;load-&gt;database();<br />就不需要重复连接, 在那个控制器或模型就可以做任意多次的查询。</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);"><br /><span style="color: rgb(255, 0, 0);">查询操作(等同select)</span><br />方法一:<br />$query = $this-&gt;db-&gt;get(&#39;sites&#39;); //sites为表名<br />这是一个&ldquo;select *&rdquo;查询,目标是site表。换句话说,它取回所有的行<br />也可用下面这种方式写:<br />$this-&gt;db-&gt;from(&#39;sites&#39;);<br />$query = $this-&gt;db-&gt;get();<br />如果想要得到特定的列,而不是全部列,这样做:<br />$this-&gt;db-&gt;select(&#39;url&#39;,&#39;name&#39;,&#39;clientid&#39;);//&#39;url&#39;,&#39;name&#39;,&#39;clientid&#39;为列名<br />$query = $this-&gt;db-&gt;get(&#39;sites&#39;);<br />如果排序:<br />$this-&gt;db-&gt;select(&#39;url&#39;,&#39;name&#39;,&#39;clientid&#39;);//&#39;url&#39;,&#39;name&#39;,&#39;clientid&#39;为列名<br />$this-&gt;db-&gt;orderby(&quot;name&quot;, &quot;desc&quot;);<br />$query = $this-&gt;db-&gt;get(&#39;sites&#39;);<br />如果想要限制返回的行数,比如想要最初五个结果<br />$this-&gt;db-&gt;select(&#39;url&#39;,&#39;name&#39;,&#39;clientid&#39;);//&#39;url&#39;,&#39;name&#39;,&#39;clientid&#39;为列名<br />$this-&gt;db-&gt;orderby(&quot;name&quot;, &quot;desc&quot;);<br />$this-&gt;db-&gt;limit(5);<br />$query = $this-&gt;db-&gt;get(&#39;sites&#39;);<br />写where语句<br />==的情况<br />$this-&gt;db-&gt;where(&#39;clientid&#39;, &#39;1&#39;);&nbsp; //clientid属性&nbsp; &quot;1&quot;为属性值<br />!=的情况<br />$this-&gt;db-&gt;where(&#39;url !=&#39;, &#39;www.mysite.com&#39;);<br />$this-&gt;db-&gt;where(&#39;id &gt;&#39;, &#39;3&#39;);<br />where后几个条件的可以写几个where 如<br />$this-&gt;db-&gt;where(&#39;url !=&#39;,&#39;www.mysite.com&#39;);<br />$this-&gt;db-&gt;where(&#39;id &gt;&#39;, &#39;3&#39;);<br />WHERE&hellip;OR的情况<br />$this-&gt;db-&gt;where(&#39;url !=&#39;,&#39;www.mysite.com&#39; );<br />$this-&gt;db-&gt;orwhere(&#39;url !=&#39;,&#39;www.anothersite.com&#39; );<br />连接表<br />$this-&gt;db-&gt;from(&#39;sites&#39;);<br />$this-&gt;db-&gt;join(&#39;people&#39;, &#39;sites.peopleid = people.id&#39;);<br />写个完整的查询<br />$this-&gt;db-&gt;select(&#39;url&#39;,&#39;name&#39;,&#39;clientid&#39;,&#39;people.surname AS client&#39;);<br />$this-&gt;db-&gt;where(&#39;clientid&#39;, &#39;3&#39;);<br />$this-&gt;db-&gt;limit(5);<br />$this-&gt;db-&gt;from(&#39;sites&#39;);<br />$this-&gt;db-&gt;join(&#39;people&#39;, &#39;sites.clientid = people.id&#39;);<br />$this-&gt;db-&gt;orderby(&quot;name&quot;, &quot;desc&quot;);<br />$query = $this-&gt;db-&gt;get();<br />方法二:<br />$this-&gt;db-&gt;query(&quot;SELECT id, name, url FROM sites WHERE &#39;type&#39; = &#39;dynamic&#39;&quot;);<br />可以像下面的语句一样写查询放条件<br />$condition = &quot;client =&#39;3&#39; AND (type =&#39;dynamic&#39; OR type=&#39;static&#39;)&quot;;<br />$this-&gt;db-&gt;where($condition);<br />注意:双引号是定义变量的.不要混淆单引号和双引号.</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);"><br /><span style="color: rgb(255, 0, 0);">显示查询结果</span><br />在查询语句后加上下面这句话<br />$query = $this-&gt;db-&gt;get();<br />如果有多个结果,他们被保存在$row对象中,可以用一个 foreach 循环:<br />foreach ($query-&gt;result() as $row)<br />{<br />&nbsp;&nbsp; print $row-&gt;url;<br />&nbsp;&nbsp; print $row-&gt;name;<br />&nbsp;&nbsp; print $row-&gt;client;<br />}<br />如果我们只想要一个结果,它可以作为一个对象被返回, 或在这里当做一个$row数组<br />if ($query-&gt;num_rows() &gt; 0)<br />{<br />&nbsp;&nbsp; $row = $query-&gt;row_array();<br />&nbsp;<br />&nbsp;&nbsp; print $row[&#39;url&#39;];<br />&nbsp;&nbsp; print $row[&#39;name&#39;];<br />&nbsp;&nbsp; print $row[&#39;client&#39;];<br />}</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);"><br /><span style="color: rgb(255, 0, 0);"><strong>增加数据(等同insert)</strong></span><br />方法一:先建个数组,把要insert的值放在数组里.如下:其中url/name/clientid/type均为数据表属性值<br />$data = array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;url&#39; =&gt; &#39;www.mynewclient.com&#39;,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;name&#39; =&gt; &#39;BigCo Inc&#39;,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;clientid&#39; =&gt; &#39;33&#39;,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;type&#39; =&gt; &#39;dynamic&#39;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<br />然后使用$this-&gt;db-&gt;insert(&#39;sites&#39;, $data); 把数据增加到sites表中.<br />方法二:使用$this-&gt;db-&gt;set() 设置每一个值<br />$this-&gt;db-&gt;set(&#39;url&#39;, &#39;www.mynewclinet.com&#39;);<br />$this-&gt;db-&gt;set(&#39;name&#39;, &#39;BigCo Inc&#39;);<br />$this-&gt;db-&gt;set(&#39;clientid&#39;, &#39;33&#39;);<br />$this-&gt;db-&gt;set(&#39;type&#39;, &#39;dynamic&#39;);<br />$this-&gt;db-&gt;insert(&#39;sites&#39;);</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);"><br /><span style="color: rgb(255, 0, 0);"><strong>更新(等同update)</strong></span><br />先定位要更新的记录,再update<br />$this-&gt;db-&gt;where(&#39;id&#39;, &#39;1&#39;);<br />$this-&gt;db-&gt;update(&#39;sites&#39;, $data);<br />$this-&gt;db-&gt;set()方式也可以,和新增数据应该是一样的.</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);">&nbsp;</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);">CI 提供几个函数检查数据库是否成功执行了相关操作。 最有用的:<br />$this-&gt;db-&gt;affected_rows();<br />在执行insert或update后应该返回 &#39;1&#39;-但是如果我正在update一批记录的话,可能返回更大的一个整数。</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);"><br />如果我正在insert一笔新的记录, 在实际产生它之前,我们并不知道ID具体的值。如果我需要引用新的记录的ID, 使用下列语句:<br />$new_id_number = $this-&gt;db-&gt;insert_id();</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);"><br /><span style="color: rgb(255, 0, 0);"><strong>删除(等同delete)</strong></span><br />$this-&gt;db-&gt;where(&#39;id&#39;, &#39;2&#39;);<br />$this-&gt;db-&gt;delete(&#39;sites&#39;);</p><p style="font-family: Arial; font-size: 14px; line-height: 26px; color: rgb(51, 51, 51);">&nbsp;</p><p style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="font-family: 'Microsoft Yahei', Hei, Tahoma, SimHei, sans-serif; color: rgb(51, 51, 51);">CI中使用多个数据库</span></p><p style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="font-family: 'Microsoft Yahei', Hei, Tahoma, SimHei, sans-serif; color: rgb(51, 51, 51);"><span style="color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp;</span><span style="word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">第一步:创建数据库</span><br style="word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp; 现在假设我要操作的两个数据库分别为我本机MySQL数据库中的</span><span style="word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">test</span><span style="color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">数据库和</span><span style="word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">test_othe</span><span style="color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">r数据库。</span><br style="word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp; test数据库中有一个t_news表(新闻表);</span><br style="word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp; 其SQL语句如下:</span><br style="word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp;</span></span></p><div class="blockcode" style="font-size: 14px; word-wrap: break-word; overflow: hidden; margin: 10px 0px; padding: 10px 0px 5px 10px; color: rgb(102, 102, 102); zoom: 1; border: 1px solid rgb(204, 204, 204); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;"><div style="word-wrap: break-word; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(214, 214, 214); margin: 0em 1em 0em 3em; color: black; position: relative;">SQL<span style="word-wrap: break-word; margin-left: 43px; font-size: 12px; position: absolute; right: 0px; color: rgb(51, 102, 153) !important;">复制代码</span></div><div id="code_oUb" style="word-wrap: break-word;"><div class="sql" style="word-wrap: break-word; font-family: monospace; margin: 1em 1em 1em 3em; line-height: 1.6em;">&nbsp;<br style="word-wrap: break-word;" /><span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">CREATE</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DATABASE</span>&nbsp;<span class="coMULTI" style="word-wrap: break-word; color: rgb(128, 128, 128); font-style: italic;">/*!32312 IF NOT EXISTS*/</span><span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`test`</span>&nbsp;<span class="coMULTI" style="word-wrap: break-word; color: rgb(128, 128, 128); font-style: italic;">/*!40100 DEFAULT CHARACTER SET utf8 */</span>;<br style="word-wrap: break-word;" /><span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">USE</span>&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`test`</span>;<br style="word-wrap: break-word;" /><span class="coMULTI" style="word-wrap: break-word; color: rgb(128, 128, 128); font-style: italic;">/*Table structure for table `t_news` */</span><br style="word-wrap: break-word;" /><span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DROP</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">TABLE</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">IF</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">EXISTS</span>&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`t_news`</span>;<br style="word-wrap: break-word;" /><span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">CREATE</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">TABLE</span>&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`t_news`</span>&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`id`</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">INT</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">11</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NOT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">AUTO_INCREMENT</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;新闻ID&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`title`</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">CHAR</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">255</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NOT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;新闻标题&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`sub_title`</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">VARCHAR</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">500</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;新闻副标题&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`content`</span>&nbsp;TEXT COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;新闻内容&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`create_time`</span>&nbsp;DATETIME&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;创建时间&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`hits`</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">INT</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">11</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;点击率&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`author`</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">CHAR</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">50</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;作者&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`source`</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">CHAR</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">255</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;信息来源&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">PRIMARY</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">KEY</span>&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`id`</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span><br style="word-wrap: break-word;" /><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;ENGINE<span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span>INNODB&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">AUTO_INCREMENT</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">0</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;CHARSET<span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span>utf8 CHECKSUM<span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">1</span>&nbsp;DELAY_KEY_WRITE<span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">1</span>ROW_FORMAT<span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span>DYNAMIC COMMENT<span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span><span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;新闻表&#39;</span>;</div></div><span style="word-wrap: break-word; margin-left: 43px; font-size: 12px; color: rgb(51, 102, 153) !important;">复制代码</span></div><br style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp; test_other数据库中有一个t_sys_user(系统管理员表);</span><br style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp; 其SQL语句如下:</span><br style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp;</span><div class="blockcode" style="font-size: 14px; word-wrap: break-word; overflow: hidden; margin: 10px 0px; padding: 10px 0px 5px 10px; color: rgb(102, 102, 102); zoom: 1; border: 1px solid rgb(204, 204, 204); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;"><div style="word-wrap: break-word; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(214, 214, 214); margin: 0em 1em 0em 3em; color: black; position: relative;">SQL<span style="word-wrap: break-word; margin-left: 43px; font-size: 12px; position: absolute; right: 0px; color: rgb(51, 102, 153) !important;">复制代码</span></div><div id="code_aPd" style="word-wrap: break-word;"><div class="sql" style="word-wrap: break-word; font-family: monospace; margin: 1em 1em 1em 3em; line-height: 1.6em;">&nbsp;<br style="word-wrap: break-word;" /><span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">CREATE</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DATABASE</span>&nbsp;<span class="coMULTI" style="word-wrap: break-word; color: rgb(128, 128, 128); font-style: italic;">/*!32312 IF NOT EXISTS*/</span><span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`test_other`</span>&nbsp;<span class="coMULTI" style="word-wrap: break-word; color: rgb(128, 128, 128); font-style: italic;">/*!40100 DEFAULT CHARACTER SET utf8 */</span>;<br style="word-wrap: break-word;" /><span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">USE</span>&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`test_other`</span>;<br style="word-wrap: break-word;" /><span class="coMULTI" style="word-wrap: break-word; color: rgb(128, 128, 128); font-style: italic;">/*Table structure for table `t_sys_user` */</span><br style="word-wrap: break-word;" /><span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DROP</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">TABLE</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">IF</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">EXISTS</span>&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`t_sys_user`</span>;<br style="word-wrap: break-word;" /><span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">CREATE</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">TABLE</span>&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`t_sys_user`</span>&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`id`</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">INT</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">11</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NOT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;管理员ID&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`role_id`</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">INT</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">11</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NOT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;角色ID&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`login_name`</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">VARCHAR</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">50</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NOT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;用户名称&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`password`</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">VARCHAR</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">255</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NOT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;密码&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`is_admin`</span>&nbsp;TINYINT<span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">1</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NOT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;0&#39;</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;是否为管理员(0:否 1:是)&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`create_time`</span>&nbsp;DATETIME&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;创建时间&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`last_login`</span>&nbsp;DATETIME&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;上次登录时间&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`login_num`</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">INT</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">11</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;0&#39;</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;登录次数&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`last_ip`</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">CHAR</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">15</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;上次登录IP&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`status`</span>&nbsp;TINYINT<span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">1</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NOT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;0&#39;</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;登录状态(0:未登录 1:已登录)&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`is_locked`</span>&nbsp;TINYINT<span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">1</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NOT</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">NULL</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;0&#39;</span>&nbsp;COMMENT&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;是否被锁定(0:否 1:是 注:锁定时不允许登录)&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">,</span><br style="word-wrap: break-word;" />&nbsp;&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">PRIMARY</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">KEY</span>&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">(</span><span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">`id`</span><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span><br style="word-wrap: break-word;" /><span class="br0" style="word-wrap: break-word; color: rgb(102, 204, 102);">)</span>&nbsp;ENGINE<span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span>INNODB&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(153, 51, 51);">DEFAULT</span>&nbsp;CHARSET<span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span>utf8 CHECKSUM<span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">1</span>&nbsp;DELAY_KEY_WRITE<span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">1</span>&nbsp;ROW_FORMAT<span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span>DYNAMIC COMMENT<span class="sy0" style="word-wrap: break-word; color: rgb(102, 204, 102);">=</span><span class="st0" style="word-wrap: break-word; color: rgb(255, 0, 0);">&#39;系统管理员表&#39;</span>;</div></div><span style="word-wrap: break-word; margin-left: 43px; font-size: 12px; color: rgb(51, 102, 153) !important;">复制代码</span></div><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp;</span><span style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">第二步:修改数据库配置信息</span><br style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp; 打开./application/config/目录中的</span><span style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">database.php</span><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">文件,在原来的内容中增加另外一个数据库配置信息。文件内容如下:</span><br style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp;</span><div class="blockcode" style="font-size: 14px; word-wrap: break-word; overflow: hidden; margin: 10px 0px; padding: 10px 0px 5px 10px; color: rgb(102, 102, 102); zoom: 1; border: 1px solid rgb(204, 204, 204); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;"><div style="word-wrap: break-word; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(214, 214, 214); margin: 0em 1em 0em 3em; color: black; position: relative;">PHP<span style="word-wrap: break-word; margin-left: 43px; font-size: 12px; position: absolute; right: 0px; color: rgb(51, 102, 153) !important;">复制代码</span></div><div id="code_Z9p" style="word-wrap: break-word;"><div class="php" style="word-wrap: break-word; font-family: monospace; margin: 1em 1em 1em 3em; line-height: 1.6em;">&nbsp;<br style="word-wrap: break-word;" /><span class="kw2" style="word-wrap: break-word; color: rgb(0, 0, 0);">&lt;?php</span>&nbsp;&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(177, 177, 0);">if</span>&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">!</span>&nbsp;<span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">defined</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;BASEPATH&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 0, 96);">&nbsp;</span><span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">exit</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;No direct script access allowed&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="coMULTI" style="word-wrap: break-word; color: rgb(0, 0, 96); font-style: italic;">/*<br style="word-wrap: break-word;" />| -------------------------------------------------------------------<br style="word-wrap: break-word;" />| DATABASE CONNECTIVITY SETTINGS<br style="word-wrap: break-word;" />| -------------------------------------------------------------------<br style="word-wrap: break-word;" />| This file will contain the settings needed to access your database.<br style="word-wrap: break-word;" />|<br style="word-wrap: break-word;" />| For complete instructions please consult the &#39;Database Connection&#39;<br style="word-wrap: break-word;" />| page of the User Guide.<br style="word-wrap: break-word;" />|<br style="word-wrap: break-word;" />| -------------------------------------------------------------------<br style="word-wrap: break-word;" />| EXPLANATION OF VARIABLES<br style="word-wrap: break-word;" />| -------------------------------------------------------------------<br style="word-wrap: break-word;" />*/</span><br style="word-wrap: break-word;" /><span style="color: rgb(0, 0, 96);">&nbsp;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$active_group</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$active_record</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">TRUE</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp;<br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;hostname&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;localhost&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;username&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;root&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;password&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;111111&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;database&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;test&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;dbdriver&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;mysql&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;dbprefix&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;pconnect&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">FALSE</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;db_debug&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">TRUE</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;cache_on&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">FALSE</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;cachedir&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;char_set&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;utf8&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;dbcollat&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;utf8_general_ci&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;swap_pre&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;autoinit&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">TRUE</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;stricton&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">FALSE</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp;<br style="word-wrap: break-word;" /><span class="co1" style="word-wrap: break-word; font-style: italic;">//Additional database</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;hostname&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;localhost&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;username&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;root&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;password&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;111111&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;database&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;test_other&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;dbdriver&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;mysql&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;dbprefix&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;pconnect&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">FALSE</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;db_debug&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">TRUE</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;cache_on&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">FALSE</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;cachedir&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;char_set&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;utf8&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;dbcollat&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;utf8_general_ci&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;swap_pre&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;autoinit&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">TRUE</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;stricton&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">FALSE</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp;<br style="word-wrap: break-word;" /><span class="coMULTI" style="word-wrap: break-word; font-style: italic;">/* End of file database.php */</span><br style="word-wrap: break-word;" /><span class="coMULTI" style="word-wrap: break-word; font-style: italic;">/* Location: ./application/config/database.php */</span></div></div><span style="word-wrap: break-word; margin-left: 43px; font-size: 12px; color: rgb(51, 102, 153) !important;">复制代码</span></div><br style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><br style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp; 第三步:编写控制器</span><br style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp; 在./application/controllers/目录下创建名为</span><span style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">dbc.php</span><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">的控制器文件,其内容如下:</span><br style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp;</span><div class="blockcode" style="font-size: 14px; word-wrap: break-word; overflow: hidden; margin: 10px 0px; padding: 10px 0px 5px 10px; color: rgb(102, 102, 102); zoom: 1; border: 1px solid rgb(204, 204, 204); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;"><div style="word-wrap: break-word; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(214, 214, 214); margin: 0em 1em 0em 3em; color: black; position: relative;">PHP<span style="word-wrap: break-word; margin-left: 43px; font-size: 12px; position: absolute; right: 0px; color: rgb(51, 102, 153) !important;">复制代码</span></div><div id="code_yyJ" style="word-wrap: break-word;"><div class="php" style="word-wrap: break-word; font-family: monospace; margin: 1em 1em 1em 3em; line-height: 1.6em;">&nbsp;<br style="word-wrap: break-word;" /><span class="kw2" style="word-wrap: break-word; color: rgb(0, 0, 0);">&lt;?php</span>&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(177, 177, 0);">if</span>&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">!</span>&nbsp;<span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">defined</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;BASEPATH&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 0, 96);">&nbsp;</span><span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">exit</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;No direct script access allowed&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="co4" style="word-wrap: break-word; color: rgb(0, 153, 51); font-style: italic;">/**<br style="word-wrap: break-word;" />&nbsp;* @package &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CI2.1.0<br style="word-wrap: break-word;" />&nbsp;* @author &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Longde<br style="word-wrap: break-word;" />&nbsp;* @version &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1.0<br style="word-wrap: break-word;" />&nbsp;*/</span><br style="word-wrap: break-word;" /><span style="color: rgb(0, 0, 96);">&nbsp;</span><br style="word-wrap: break-word;" /><span class="co1" style="word-wrap: break-word; font-style: italic;">// ------------------------------------------------------------------------</span><br style="word-wrap: break-word;" /><span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">header</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;Content-Type:text/html; charset=utf-8&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span class="co4" style="word-wrap: break-word; color: rgb(0, 153, 51); font-style: italic;">/**<br style="word-wrap: break-word;" />&nbsp;* 数据库控制器<br style="word-wrap: break-word;" />&nbsp;* 该控制器的主要做用是进行数据库方面的操作。<br style="word-wrap: break-word;" />&nbsp;*&nbsp;<br style="word-wrap: break-word;" />&nbsp;* @category &nbsp; &nbsp; &nbsp; &nbsp;Controllers<br style="word-wrap: break-word;" />&nbsp;* @author &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Longde<br style="word-wrap: break-word;" />&nbsp;*/</span><br style="word-wrap: break-word;" /><span class="kw2" style="word-wrap: break-word; color: rgb(0, 0, 0);">class</span><span style="color: rgb(0, 0, 96);">&nbsp;Dbc&nbsp;</span><span class="kw2" style="word-wrap: break-word; color: rgb(0, 0, 0);">extends</span>&nbsp;CI_Controller&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">{</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co4" style="word-wrap: break-word; color: rgb(0, 153, 51); font-style: italic;">/**<br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* 测试在同一个项目中同时使用多个数据库进行操作<br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @access &nbsp; &nbsp; &nbsp; &nbsp;public<br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @return &nbsp; &nbsp; &nbsp; &nbsp;array<br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="kw2" style="word-wrap: break-word; color: rgb(0, 0, 0);">public</span>&nbsp;<span class="kw2" style="word-wrap: break-word; color: rgb(0, 0, 0);">function</span>&nbsp;index<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">{</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//按照CI手册中的说法:如果需要同时连接多个数据库,则采用</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//$DB1 = $this-&gt;load-&gt;database(&#39;group_one&#39;,TRUE);</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//$DB2 = $this-&gt;load-&gt;database(&#39;group_two&#39;,TRUE);</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//注意:confing/database.php中的$db[xxxx][&#39;pconnect&#39;] = FALSE</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db1</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$this</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">load</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">database</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;default&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">TRUE</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><span class="co1" style="word-wrap: break-word; font-style: italic;">//注意第一个参数:值与配置文件中的第一个索引对应</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db2</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$this</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">load</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">database</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;additional&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span>&nbsp;<span class="kw4" style="word-wrap: break-word; color: rgb(0, 153, 0);">TRUE</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><span class="co1" style="word-wrap: break-word; font-style: italic;">//注意第一个参数:值与配置文件中的第一个索引对应</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//下面开始进行操作</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//首先,在第一个数据库test的t_news表中插入数据</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$data1</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">array</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><br style="word-wrap: break-word;" /><span style="color: rgb(0, 0, 96);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;title&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;测试在CI框架中同时操作多个数据库&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;sub_title&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;CI框架允许使用多个数据库进行操作。具体的内容请查看CI手册......&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;content&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;如果你需要同时连接多于一个的数据库,你可以用以下方式来实现:$DB1 = $this-&gt;load-&gt;database(/&#39;group_one/&#39;, TRUE);$DB2 = $this-&gt;load-&gt;database(/&#39;group_two/&#39;, TRUE);注意:改变 &quot;group_one&quot; 和 &quot;group_two&quot; 为你指定了连接属性的组名 (或者通过上边说过的连接数组的数组名)。&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;create_time&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">date</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;Y-m-d H:i:s&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><br style="word-wrap: break-word;" /><span style="color: rgb(0, 0, 96);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;author&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;Longde&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;source&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;原创&#39;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//插入之前先判断是否已存在</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db1</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">select</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;id&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$id1</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db1</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">get_where</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;t_news&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">array</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;title&#39;</span><span style="color: rgb(0, 0, 96);">&nbsp;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$data1</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;title&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">result_array</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(177, 177, 0);">if</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">empty</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$id1</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><br style="word-wrap: break-word;" /><span style="color: rgb(0, 0, 96);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">{</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//插入数据</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db1</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">insert</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;t_news&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$data1</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//获取刚才插入数据时生成的ID值</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$id1</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db1</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">insert_id</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">}</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(177, 177, 0);">else</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">{</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$id1</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$id1</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">0</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;id&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">}</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//从数据库中读取数据</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$result1</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db1</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">get_where</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;t_news&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">array</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;id&#39;</span><span style="color: rgb(0, 0, 96);">&nbsp;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$id1</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">result_array</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//格式化输出刚才的读取结果</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(177, 177, 0);">echo</span>&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(0, 0, 255);">&quot;&lt;pre&gt;&quot;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">print_r</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$result1</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span style="color: rgb(0, 0, 96);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//其次,在第二个数据库test_other的t_sys_user表中插入数据</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$data2</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">array</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><br style="word-wrap: break-word;" /><span style="color: rgb(0, 0, 96);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;role_id&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">1</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;login_name&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;admin&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;password&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">md5</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;admin&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><br style="word-wrap: break-word;" /><span style="color: rgb(0, 0, 96);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;is_admin&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">1</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;create_time&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">date</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;Y-m-d H:i:s&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><br style="word-wrap: break-word;" /><span style="color: rgb(0, 0, 96);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;status&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">0</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;is_locked&#39;</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">0</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//插入之前先判断是否已存在</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db2</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">select</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;id&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$id2</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db2</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">get_where</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;t_sys_user&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">array</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;login_name&#39;</span><span style="color: rgb(0, 0, 96);">&nbsp;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$data2</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;login_name&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">result_array</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(177, 177, 0);">if</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">empty</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$id2</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><br style="word-wrap: break-word;" /><span style="color: rgb(0, 0, 96);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">{</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//插入数据</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db2</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">insert</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;t_sys_user&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$data2</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//获取刚才插入数据时生成的ID值</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$id2</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db2</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">insert_id</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">}</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(177, 177, 0);">else</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">{</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$id2</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$id2</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="nu0" style="word-wrap: break-word; color: rgb(204, 102, 204);">0</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">[</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;id&#39;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">]</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">}</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//从数据库中读取刚才插入的数据</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$result2</span>&nbsp;<span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$db2</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">get_where</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;t_sys_user&#39;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">,</span><span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">array</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="st_h" style="word-wrap: break-word; color: rgb(0, 0, 255);">&#39;id&#39;</span><span style="color: rgb(0, 0, 96);">&nbsp;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">=&gt;</span>&nbsp;<span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$id2</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">-&gt;</span><span class="me1" style="word-wrap: break-word; color: rgb(0, 64, 0);">result_array</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">//格式化输出刚才的读取结果</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="kw1" style="word-wrap: break-word; color: rgb(177, 177, 0);">echo</span>&nbsp;<span class="st0" style="word-wrap: break-word; color: rgb(0, 0, 255);">&quot;&lt;pre&gt;&quot;</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="kw3" style="word-wrap: break-word; color: rgb(153, 0, 0);">print_r</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">(</span><span class="re0" style="word-wrap: break-word; color: rgb(0, 0, 136);">$result2</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">)</span><span class="sy0" style="word-wrap: break-word; color: rgb(51, 153, 51);">;</span><br style="word-wrap: break-word;" /><span style="color: rgb(0, 0, 96);">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">}</span><br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br style="word-wrap: break-word;" />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="co1" style="word-wrap: break-word; font-style: italic;">// ------------------------------------------------------------------------</span><br style="word-wrap: break-word;" /><span class="br0" style="word-wrap: break-word; color: rgb(0, 153, 0);">}</span><br style="word-wrap: break-word;" />&nbsp;<br style="word-wrap: break-word;" /><span class="coMULTI" style="word-wrap: break-word; font-style: italic;">/* End of file dbc.php */</span><br style="word-wrap: break-word;" /><span class="coMULTI" style="word-wrap: break-word; font-style: italic;">/* Location: ./application/controllers/dbc.php */</span></div></div><span style="word-wrap: break-word; margin-left: 43px; font-size: 12px; color: rgb(51, 102, 153) !important;">复制代码</span></div><br style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><br style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp; 说明一下,dbc.php文件中的index()方法主要是对两个数据库分别进行了插入操作,但在插入操作之前,先对该条记录是否存在进行了判断,如果存在则不进行插入操作并直接查询出结果;否则先进行插入,然后再查询。</span><br style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;" /><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp; 值得注意的是,数据库配置文件database.php文件中的$db[&#39;group_name&#39;][&#39;pconnect&#39;]值需要设置为</span><span style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">FALSE</span><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">,其次$db[&#39;</span><span style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">group_name</span><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&#39;]中的索引group_name对应的就是&ldquo;$DB1 = $this-&gt;load-&gt;database(&#39;</span><span style="font-size: 14px; word-wrap: break-word; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">group_name</span><span style="font-size: 14px; color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&#39;,TRUE)&rdquo;;</span><br style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;" /><p style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;">&nbsp;</p><p style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="font-family: 'Microsoft Yahei', Hei, Tahoma, SimHei, sans-serif; color: rgb(51, 51, 51);"><span style="color: rgb(68, 68, 68); font-family: Tahoma, 'Microsoft Yahei', Simsun; line-height: 21px;">&nbsp;如果文件保存完成后,通过站点访问即可看到查询出来的数据则说明多个数据库操作实现成功。</span></span></p>
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜