Welcome Guest, Not a member yet? Register   Sign In
MySQL Data Retrieval
#3

[eluser]bhogg[/eluser]
Sure, here is the part that reloads the data, the rest just checks to make sure it's a valid id. Note that readonly_defn is an empty array.

Code:
$CI =& get_instance();
            $db = $CI->db;

            // Build the select portion of the query, and join readonly values
            $select = self::TABLE.".*";
            $db->from(self::TABLE);
            foreach ($this->_readonly_defn as $field => $arr)
            {
                foreach ($arr as $value => $condition)
                {
                    $select .= ", {$value} as {$field}";
                    $db->join(substr($value, 0, strpos($value, ".")), $condition, 'left');
                }
            }
            $db->select($select);

            // Get only the applicable row
            $db->where(array(self::TABLE.'.id' => $id));

            // Get the results and update our internal data
            $query = $db->get();
            if ($query->num_rows())
            {
                $this->_data = $query->row_array();
                foreach ($this->_readonly_defn as $field => $arr)
                {
                    $this->_readonly[$field] = $this->_data[$field];
                    unset($this->_data[$field]);
                }
            }


Messages In This Thread
MySQL Data Retrieval - by El Forum - 06-17-2009, 11:12 AM
MySQL Data Retrieval - by El Forum - 06-17-2009, 11:58 AM
MySQL Data Retrieval - by El Forum - 06-17-2009, 05:19 PM
MySQL Data Retrieval - by El Forum - 06-17-2009, 11:51 PM
MySQL Data Retrieval - by El Forum - 06-18-2009, 02:16 AM
MySQL Data Retrieval - by El Forum - 07-01-2009, 01:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB