Welcome Guest, Not a member yet? Register   Sign In
Does Active Record scan the table before any model functions are called?
#11

[eluser]Randy Casburn[/eluser]
Oh...I forgot about that part. They have sales all the time though :lol:
#12

[eluser]taewoo[/eluser]
I know this is out of scope but this "web 2.0 - pay for nothing - get everything for free" movement, in my opinion, is lame. If you provide good product (or service... as in case of web 2.0), you should get paid. Why should software be any different than.. a car that you purchase. If it gives you good experience, than the maker deserves financial reward. Besides, isn't that the whole reason why you guys start your own companies or work for companies? No pay = no income = no company (or job).

Besides, it's $495 b/c the market size is tiny. How many developers are there in the world? Maybe 10 million AT best (i.e. China and India) Simple mathematics. You charge more than what it cost you. If the customer base is small, u have to charge more. (for example... Pixar Renderman, Oracle DB, Photoshop, etc etc)
#13

[eluser]m4rw3r[/eluser]
@topic
I think the reference is to IgnitedRecord (maybe, I dunno), because IgnitedRecord uses SHOW COLUMNS FROM... before it cleans the record object before a save.

This can be circumvented by specifying the columns yourself.

Note: This answer may not be what you asked for, so please ignore if it isn't.
#14

[eluser]Randy Casburn[/eluser]
Maybe...

Quote:Perhaps this person was looking at some Add on component

Well, you're the boss when it comes to that. I suppose it's kind of hard to "do the magic" without the "magic" part. It is what it is (ORM I mean). I suppose you could make this aspect very explicit in the docs. Dunno...

@taewoo -- maybe you could ask.

Randy
#15

[eluser]taewoo[/eluser]
in system/database/drivers/mysql/mysql_driver.php

there is a function that does "SHOW COLUMNS FROM <table>"
Code:
function _list_columns($table = '')
    {
        return "SHOW COLUMNS FROM ".$this->_escape_table($table);
    }

which is called by /system/database/drivers/mssql/mssql_driver.php:
Code:
function list_fields($table = '')
    {
        // Is there a cached result?
        if (isset($this->data_cache['field_names'][$table]))
        {
            return $this->data_cache['field_names'][$table];
        }
  
        if ($table == '')
        {
            if ($this->db_debug)
            {
                return $this->display_error('db_field_param_missing');
            }
            return FALSE;          
        }
      
        if (FALSE === ($sql = $this->_list_columns($this->dbprefix.$table)))
        {
            if ($this->db_debug)
            {
                return $this->display_error('db_unsupported_function');
            }
            return FALSE;      
        }
      
        $query = $this->query($sql);
      
        $retval = array();
        foreach($query->result_array() as $row)
        {
            if (isset($row['COLUMN_NAME']))
            {
                $retval[] = $row['COLUMN_NAME'];
            }
            else
            {
                $retval[] = current($row);
            }      
        }
      
        $this->data_cache['field_names'][$table] = $retval;
        return $this->data_cache['field_names'][$table];
    }
But i can't find anywhere that uses this function "field_exists" anywhere.
#16

[eluser]Randy Casburn[/eluser]
DB_Driver line 858.

(the beauty of the IDE ;-) )
#17

[eluser]taewoo[/eluser]
So does this mean that the developer is right? That CodeIgniter ACtiveRecord does indeed scan the table prior to model execution?

PS: I use something fancier - "grep"
#18

[eluser]m4rw3r[/eluser]
No, it is only the db_driver::list_fields(), db_result::list_fields() and table::generate() (when passing a db_object) that calls list_fields().

So it only calls it if you ask for it Smile
#19

[eluser]Randy Casburn[/eluser]
mr4rw3r is correct, the answer is still no. What you have discovered are the methods that "do the dirty deed" in order to answer questions - but ONLY when asked for information that requires "the dirty deed" to be done. This in no way implies:
Quote:it scans the corresponding table everytime (for mapping fields with schema) before executing
----
Quote:But i can’t find anywhere that uses this function “field_exists” anywhere.

I misunderstood...I thought you said "I can't find". without reading the part "that uses".

That's because the method “field_exists” is a "user space" method and is not used internally by CI at all. Again, it only does "the dirty deed" if the user requests information that requires the information to be derived from "doing the dirty deed".
----

This is why when you read articles that compare CI to other frameworks "they" say CI uses a pseudo non-ORM implementation.

For some more information to feed to your developer, here are a couple of links to share:

http://en.wikipedia.org/wiki/Object-Rela...e_mismatch
http://dossy.org/archives/000385.html

ORM is what it is. Any time you use objects to abstract a database, you must use some method of "scanning the database" to extract the underlying structure for the sole purpose of putting that structure into objects. There are only a couple of different methods of doing this, but they both basically arrive at the same conclusion. Namely, scanning the db so objects can be created from the structure of the db tables.

Have you developer friend go decompose Rails Active Record.

Hope this has been helpful.

Randy
#20

[eluser]taewoo[/eluser]
Thanks Randy.
Quote:That’s because the method “field_exists” is a “user space” method and is not used internally by CI at all. Again, it only does “the dirty deed” if the user requests information that requires the information to be derived from “doing the dirty deed”.

That's what I thought. Just wanted 3rd party verification.

Who da man? Yo(u)-da man!




Theme © iAndrew 2016 - Forum software by © MyBB