• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Suggestions Please For Library File

[eluser]Tim Brownlaw[/eluser]
$this->input->post returns a value or FALSE...(Read the User guide to check the Return Values on things like this...) unless you are testing that elsewhere and setting it to null when it's False ie does not exist!!!

if ($this->input->post('some_key') !== FALSE) {
// Hopefully we are performing some validation as we're just grabbing the post value here
   $data['some_key'] = $this->input->post('some_key');
} else {
// On view would display "content of value" selected from database.
// What do we do if 'some_key' does not exist in the database? NULL is returned
   $data['some_key'] = $this->item->get('some_key');

Where/How is $data being populated... You refer to a database so I'm guessing you load this up from somewhere else using your set method or another you've not shown here.
I am also guessing that this is your item library you are calling from the above code and that the private property that you have declared... $data is the one you are really wanting to refer to!

private $data = array();
function __construct() {
public function get($key) {
   return isset($this->data[$key]) ? $this->data[$key] : null;
public function set($key, $value) {
   $this->data[$key] = $value;
public function has($key) {
   return isset($this->data[$key]);

Messages In This Thread
Suggestions Please For Library File - by El Forum - 08-31-2014, 09:10 PM
Suggestions Please For Library File - by El Forum - 08-31-2014, 10:27 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.