Return types from mysql (not the same as the last thread)
Posted: Wed Sep 27, 2006 5:09 pm
When you perform a query like this...
And you use php to iterate through the results, are they ALWAYS strings? Because I've been tinkering with this for a while and it seems no matter what type of data, it gives you, if you do a gettype() on it, it returns "string" for example:
By the way, I'm using d11's mysql result iterator here
Code: Select all
SELECT * FROM `table` WHERE id = 1Code: Select all
public function load($conditions, $fields_array=null){
$select_fields = "*";
if($fields_array) $select_fields = implode(",", $fields_array);
$sql = "SELECT " . $select_fields . " FROM `" . $this->table . "` WHERE " . $conditions . " LIMIT 1";
//echo $sql;
$result = $this->query($sql);
if($result->length()){
foreach($this->fields as $key => $value){
$value->setValue($result->{$key});
echo gettype($result->{$key}); // Always outputs "string"
}
return true;
}
return false;
}