Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Reading Models metadata: data types return numeric array

I'm trying to read a models' metadata. The connected database is mysql. Let's say the model is the Phalcon classic Robots. If i now go

<?php

$robotDataTypes = $robot->getModelsMetaData()->getDataTypes($robot);

what i would end up getting is an array of key value pairs where the value is numeric, it gives me absolutely no information what the data type really is.Something with the following structure : array('id' => 0, 'name' => 2....
and so on. Is it supposed to return that? How about the actual data type, such as string/int/datetime? What should i make of it? If there Is another method to get the data types, there seems to be zero documentation of it. Help! FYI, i'm using Phalcon version 2.03. Thanks



35.7k
Accepted
answer
edited Nov '15

PHP variables are dynamic and typeless as far as i know... and standard SQL does not have a string datatype. Please be specific...

getDataTypes will return the values of Phalcon\Db\Column::TYPE_? constants.



3.9k

Thanks. I didn't realize it would return constants, i thought it would return a string representtion instead ala 'VARCHAR' or 'DATE', even though it should have logically followed to think it would return constants.