Welcome Guest, Not a member yet? Register   Sign In
$this->db->field_data() max_length
#4

[eluser]jtkendall[/eluser]
I'm just doing the same thing as what's in the user guide. Though in the user guide it doesn't state that the field's default will be in the meta data, even though when I print the object it's there.

This is just a quick example of the code. All I do after this step is run a foreach on the fields variable and send the field metadata to another method. But that doesn't effect the object.

Code:
public function test()
{
    $fields = $this->db->field_data('test');
    echo '<pre>';
    print_r($fields);    
    echo '</pre>';
}

I was testing to see what each field type (name key in this case) returned as it's actual type and this is what's returned:

Code:
Array
(
    [0] => stdClass Object
        (
            [name] => id
            [type] => int
            [default] =>
            [max_length] => 0
            [primary_key] => 1
        )

    [1] => stdClass Object
        (
            [name] => tinyint
            [type] => int
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [2] => stdClass Object
        (
            [name] => smallint
            [type] => int
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [3] => stdClass Object
        (
            [name] => mediumint
            [type] => int
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [4] => stdClass Object
        (
            [name] => int
            [type] => int
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [5] => stdClass Object
        (
            [name] => bigint
            [type] => int
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [6] => stdClass Object
        (
            [name] => float
            [type] => real
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [7] => stdClass Object
        (
            [name] => decimal
            [type] => real
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [8] => stdClass Object
        (
            [name] => double
            [type] => real
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [9] => stdClass Object
        (
            [name] => date
            [type] => date
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [10] => stdClass Object
        (
            [name] => datetime
            [type] => datetime
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [11] => stdClass Object
        (
            [name] => timestamp
            [type] => timestamp
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [12] => stdClass Object
        (
            [name] => time
            [type] => time
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [13] => stdClass Object
        (
            [name] => year
            [type] => year
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [14] => stdClass Object
        (
            [name] => char
            [type] => string
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [15] => stdClass Object
        (
            [name] => varchar
            [type] => string
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [16] => stdClass Object
        (
            [name] => tinyblob
            [type] => blob
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [17] => stdClass Object
        (
            [name] => blob
            [type] => blob
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [18] => stdClass Object
        (
            [name] => text
            [type] => blob
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [19] => stdClass Object
        (
            [name] => mediumblob
            [type] => blob
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [20] => stdClass Object
        (
            [name] => mediumtext
            [type] => blob
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [21] => stdClass Object
        (
            [name] => longblob
            [type] => blob
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [22] => stdClass Object
        (
            [name] => longtext
            [type] => blob
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [23] => stdClass Object
        (
            [name] => enum
            [type] => string
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

    [24] => stdClass Object
        (
            [name] => set
            [type] => string
            [default] =>
            [max_length] => 0
            [primary_key] => 0
        )

)

As you can see default is empty and max_length is 0. I've set defaults on a few of the fields and all of the string and int fields have a length.


Messages In This Thread
$this->db->field_data() max_length - by El Forum - 09-27-2008, 04:04 PM
$this->db->field_data() max_length - by El Forum - 09-27-2008, 06:33 PM
$this->db->field_data() max_length - by El Forum - 09-27-2008, 10:10 PM
$this->db->field_data() max_length - by El Forum - 09-27-2008, 10:31 PM
$this->db->field_data() max_length - by El Forum - 09-27-2008, 10:47 PM
$this->db->field_data() max_length - by El Forum - 09-27-2008, 10:50 PM
$this->db->field_data() max_length - by El Forum - 09-27-2008, 11:08 PM
$this->db->field_data() max_length - by El Forum - 09-27-2008, 11:19 PM
$this->db->field_data() max_length - by El Forum - 09-27-2008, 11:37 PM
$this->db->field_data() max_length - by El Forum - 09-28-2008, 07:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB