Hi,

I have a very, very weird problem. I try to test my code and for that purpose I utilise dpm and comment out the rest of the code. When commented out, dpm shows correct values, however when I un-comment, dpm shows only one record. How come? Below is my code for reference.

<?php
function tcmb_currency_retrieve_rows($value = 'present') {
  global
$tcmb_picked_date;
   
$tcmbXML = new Domdocument;
   
$tcmbXML->load('http://www.tcmb.gov.tr/kurlar/today.xml');
   
$date = $tcmbXML->getElementsByTagName('Tarih_Date')->item(0)->getAttribute('Tarih');
   
$dateTime = DateTime::createFromFormat('d.m.Y', $date);
   
$newdate = $dateTime->format('Y-m-d');
   
$cur = tcmb_cur_codes();
   
$image = drupal_get_path('module', 'tcmb') . '/png/'. strtolower($tcmbcurcode) . '.png';
 
$curcodes = variable_get('tcmb_currencycodes', array());
 
dpm($curcodes);
  if (!
$curcodes) {
    return;
  }
  foreach (
$curcodes as $tcmbcurcode) {
   
dpm($tcmbcurcode);
   
/*
    $title = $cur[$tcmbcurcode];
    $record = db_select('tcmb', 't')
      ->fields('t', array('currency', 'buying', 'selling'))
      ->condition('currency', $tcmbcurcode)
      ->condition('`date`', $newdate)
      ->orderBy('`date`', 'DESC')
      ->groupBy('currency');
    $results = $record->execute()->fetchAll(PDO::FETCH_ASSOC);
    if (!empty($results)) {
      $rows = array();
      foreach($results as $result) {
        $rows[] = array(array('data' => theme('image', array('path' => $image, 'alt' => $title, 'title' => $title)) . " " . $result['currency'] . " " . $result['buying'] . " " . $result['selling']));
      }
      dpm($rows);
    }
    if (isset($rows)) {
      return $rows;
    }
     */
 
}
}
?>

Regards,

PS: dpm($rows) returns one value as well.

Comments

You have a return statement

You have a return statement in your foreach loop.

Sorry, what line? I fail to

Sorry, what line? I fail to see it :S

K.

nobody click here