CI_DB_active_record::from PHP Method

from() public method

Generates the FROM portion of the query
public from ( $from ) : object
return object
    function from($from)
    {
        foreach ((array) $from as $val) {
            if (strpos($val, ',') !== FALSE) {
                foreach (explode(',', $val) as $v) {
                    $v = trim($v);
                    $this->_track_aliases($v);
                    $this->ar_from[] = $this->_protect_identifiers($v, TRUE, NULL, FALSE);
                    if ($this->ar_caching === TRUE) {
                        $this->ar_cache_from[] = $this->_protect_identifiers($v, TRUE, NULL, FALSE);
                        $this->ar_cache_exists[] = 'from';
                    }
                }
            } else {
                $val = trim($val);
                // Extract any aliases that might exist.  We use this information
                // in the _protect_identifiers to know whether to add a table prefix
                $this->_track_aliases($val);
                $this->ar_from[] = $this->_protect_identifiers($val, TRUE, NULL, FALSE);
                if ($this->ar_caching === TRUE) {
                    $this->ar_cache_from[] = $this->_protect_identifiers($val, TRUE, NULL, FALSE);
                    $this->ar_cache_exists[] = 'from';
                }
            }
        }
        return $this;
    }

Usage Example

Example #1
0
 protected function _get($key, $group, $tenant_id)
 {
     $ret = false;
     $result = $this->_db->from($this->_table)->where('key', $key)->where('group', $group)->where('tenant_id', $tenant_id)->get()->result();
     if (!empty($result[0])) {
         $value = $this->_unserialize($result[0]->value);
         if ($value['expires'] > time()) {
             $ret = $value['data'];
         } else {
             $this->_delete($key, $group, $tenant_id);
         }
     }
     return $ret;
 }
All Usage Examples Of CI_DB_active_record::from