[Solved] Getting one value from row in database |
[eluser]riwakawd[/eluser]
Hi I am just wondering if I have my code correct for getting the value of my row. I need to be able to get it from the setting table with group: config, and the key: config_meta_title The value is the main item in that row I am after. Is this code correct? Model Code: function getTitle() { Not sure if need the => for select if just want to return whats in that value Controller Code: function index() {
[eluser]mohssenvox[/eluser]
hi , change your code to: Model: Code: public function getTitle() { Code: function index() {
[eluser]riwakawd[/eluser]
[quote author="mohssenvox" date="1402896839"]hi , change your code to: Model: Code: public function getTitle() { Code: function index() { Would that return the value column from that row? database looks like "setting_id, group, key, value" value is text.
[eluser]mohssenvox[/eluser]
your model query return like: "select * from your table where group="config" and key="config_meta_data" if you need only value column you can do this:"select value from your table where group="config" and key="config_meta_data"
[eluser]riwakawd[/eluser]
[quote author="mohssenvox" date="1402900450"]your model query return like: "select * from your table where group="config" and key="config_meta_data" if you need only value column you can do this:"select value from your table where group="config" and key="config_meta_data" [/quote] I tried it did not select the value from that row database http://postimg.org/image/izoi3dfg9/
[eluser]riwakawd[/eluser]
[quote author="mohssenvox" date="1402905835"]what is your table name?[/quote] $this->db->get('setting'); // Table Name http://postimg.org/image/izoi3dfg9/ $this->db->where('group', 'config'); $this->db->where('key', 'config_meta_title'); $this->db->where('value'); // Need to get content
[eluser]mohssenvox[/eluser]
use this in your model: Code: $this -> db->select("value"); Code: $this->load->model("your model");
[eluser]CroNiX[/eluser]
Code: public function getField($fieldName) {
[eluser]riwakawd[/eluser]
[quote author="CroNiX" date="1402932939"] Code: public function getField($fieldName) { Thanks for that works now. I know know what to do cheers. |
Welcome Guest, Not a member yet? Register Sign In |