Guest User

Untitled

a guest
Aug 17th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.83 KB | None | 0 0
  1. /* /application/configs/application.ini */
  2. resources.db.adapter = "mysqli"
  3. resources.db.params.host = "localhost"
  4. resources.db.params.username = "horarioe_root"
  5. resources.db.params.password = "******"
  6. resources.db.params.dbname = "horarioe_cadastro"
  7. resources.db.params.default = "true"
  8.  
  9. resources.multidb.wpress.adapter = "mysqli"
  10. resources.multidb.wpress.host = "localhost"
  11. resources.multidb.wpress.username = "horarioe_word"
  12. resources.multidb.wpress.password = "*****"
  13. resources.multidb.wpress.dbname = "horarioe_wordpress"
  14.  
  15. /* /application/modules/default/controllers/BlogController.php */
  16.  
  17. <?php
  18.  
  19. class Default_BlogController extends Zend_Controller_Action
  20. {
  21.     /*
  22.      * @TODO: Estilizar posts
  23.      * @TODO: Criar pagina��o
  24.      */
  25.    
  26.    
  27.     /*
  28.      * @returns Zend_Db_Adapter_Mysqli
  29.      */
  30.     private $db;
  31.    
  32.     public function init()
  33.     {
  34.         /* Initialize action controller here */
  35.         $configs = new Zend_Config_Ini(APPLICATION_PATH."/configs/application.ini",APPLICATION_ENV);
  36.         $config = $configs->get('resources')
  37.                 ->get('multidb')
  38.                 ->get('wpress');
  39.        
  40.         $config = $config->toArray();
  41.        
  42.         $this->db = new Zend_Db_Adapter_Mysqli($config);
  43.     }
  44.  
  45.     public function indexAction()
  46.     {
  47.         $where = "select post_date, post_title, post_content where post_status = publish";
  48.         $query = $this->db->select()
  49.                 ->from('wp_posts',array(
  50.                     'post_date',
  51.                     'post_title',
  52.                     'post_content',
  53.                    
  54.                 ))
  55.                 ->where('post_status = ?', 'publish')
  56.                 ->limit('3')
  57.                 ->order('post_date', 'desc')
  58.                 ->query();
  59.        
  60.         $this->view->posts = $query;
  61.  
  62.        
  63.     }
  64.  
  65.  
  66. }
Add Comment
Please, Sign In to add comment