CodeIgniter Forums
Recalling a field to print another one - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Recalling a field to print another one (/thread-62148.html)



Recalling a field to print another one - StratoKyke - 06-13-2015

Look at this models:

PHP Code:
public function dataList($name) {
        
$db $this->load->database('default'TRUE);
        
$db    ->select('value')
            ->
where('name'$name)
 
                       ->from('setting');
        
$query_setting $db->get('');
        return 
$query_setting->row_array();
    } 

I would make sure to enter the variable name within the template and let me return the value.

For example:
In the template I write:

Code:
{$name_site}

The template return the value of string table that have for name "name_site"

My question is. How can I build the controller?

For I use smarty template engine.


RE: Recalling a field to print another one - StratoKyke - 06-14-2015

Someone can help me? Smile


RE: Recalling a field to print another one - Blair2004 - 06-14-2015

Hi,there are many way you can get to it.
You can get result as array and save keys => value into an array you are going to pass as parameter for the view files. (Sorry I'm using in a tab, so I can't write an example )
When you say ->db->get() make sure you specify the table name or nothing if it has been declared before using ->from() method


RE: Recalling a field to print another one - StratoKyke - 06-14-2015

It is what I thought but I also do not know how to do it right ...