我有下面的代码。它只返回字符串的第一个字符。
$conn = Mage::getSingleton('core/resource')->getConnection('connection_write');
$str = 'something to search for';
$fields = 'content_field1, content_field2, content_field3, content_field4';
$idFields = 'id_field1, id_field2, id_field3, id_field4';
$tables = 'table1, table2, table3, table4';
$table = explode(', ', $tables);
$field = explode(', ', $fields);
$rowId = explode(', ', $idFields);
$i=1;
while ($i<4) {
$f = $field[$i];
$id = $rowId[$i];
$sql = $conn->select()->from($table[$i], array($f, $id))->where($f . " LIKE ?", '%' . $str . '%');
$result = $conn->fetchRow($sql);
foreach ($result as $row) {
var_dump($row[$id]);
}
$i++;
}但是,如果使用var_dump($row);,则会输出来自ID字段和内容字段的整个字符串。
任何人都可以向我解释我做错了什么?
提前致谢。