当我将纯 PHP 代码转换为 CodeIgniter 时,我遇到了原生 PHP 函数问题。对此有任何想法或替代解决方案吗?
纯 PHP 代码
$aColumns = array( 'id', 'name', 'first_name' );
$sTable = "ajax";
$sQuery = "SELECT SQL_CALC_FOUND_ROWS
".str_replace(" , ", " ", implode(", ", $aColumns))."FROM $sTable
$rResult = mysql_query( $sQuery );
while ( $aRow = mysql_fetch_assoc( $rResult ) )
{
print_r($aRow);
}
完美的结果输出
Array
(
[id] => 1
[name] => kane
[first_name] => kane
)
Array
(
[id] => 2
[name] => kane
[first_name] => kane
)
Array
(
[id] => 3
[name] => kane
[first_name] => kane
)
代码点火器
$aColumns = array( 'id', 'name', 'first_name' );
$sTable = "ajax";
$sQuery = "SELECT SQL_CALC_FOUND_ROWS
".str_replace(" , ", " ", implode(", ", $aColumns))."FROM $sTable
$rResult = $this->db->query($sQuery);
while ( $aRow = $rResult->row_array() )
{
print_r($aRow);
}
无限结果输出
Array
(
[id] => 1
[name] => kane
[first_name] => kane
)
Array
(
[id] => 1
[name] => kane
[first_name] => kane
)