I have the below code. It is only returning the first charater of a string.
$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++;
}
However, if I use var_dump($row);
the entire string from both the id fields and the content fields are outputted.
Can anyone explain to me what I am doing wrong?
Thanks in advance.
$test = "abcs"
also would act like$test = array('a','b','c','d')
so it would be accessed as$test[2]
would showc
as its the 3rd index in the array of chars! – RobertPitt Dec 29 '10 at 1:17