|
我这里有普通的PHP和MYSQL代码,想转成CI Model的。
$db_con=mysql_connect('localhost', "root", "123456789101111111111111111111");
mysql_select_db( "sasoucing",$db_con);
$sql = "SELECT * FROM cms_products ORDER BY rand() LIMIT 5;";
$result=mysql_query($sql);
// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($db_con);
|
|