Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 11th, 2012  |  syntax: None  |  size: 0.95 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Concatenate div tag to db result
  2. $divtag1 = '<div style="color:#1569C7; font-weight:bold">';
  3. $select = $this->select()
  4. ->from(array('ta' => 'tableA'),
  5. array('ta.id',
  6.       'name' => new Zend_Db_Expr("concat($divtag1 . ta.name . '</div>')"),
  7.       'date' => new Zend_Db_Expr("date(ta.date)")
  8. ));
  9.  
  10. $result = $this->getAdapter()->fetchAll($select);
  11.        
  12. SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
  13. . ta.name . '
  14. ') AS `name`, da'
  15.        
  16. 'name' => new Zend_Db_Expr("concat('$divtag1', ta.name, '</div>')"),
  17.        
  18. $divtag1 = '<div style="color:#1569C7; font-weight:bold">';
  19. $select = $this->select()
  20. ->from(array('ta' => 'tableA'),
  21. array('ta.id',
  22.       'name' => new Zend_Db_Expr("concat($divtag1 , ta.name , '</div>')"),
  23.       'date' => new Zend_Db_Expr("date(ta.date)")
  24. ));
  25.  
  26.  
  27.  
  28. $result = $this->getAdapter()->fetchAll($select);