Criar Array
Bom dia Amigos.
tenho uma função na qual me retorna os dados de um selecet.
public function selecionaCampos($objeto) {
$sql = "SELECT ";
for ($i = 0; $i < count($objeto->campos_valores); $i++) :
$sql .=key($objeto->campos_valores);
if ($i < (count($objeto->campos_valores) - 1)):
$sql.=", ";
else:
$sql .=" ";
endif;
next($objeto->campos_valores);
endfor;
$sql .= " FROM " . $objeto->tabela;
if ($objeto->extras_select != NULL) :
$sql .= " " . $objeto->extras_select;
endif;
return $this->executaSQL($sql);
}
public function retornaDados($tipo = NULL) {
switch (strtolower($tipo)) :
case "array" :
return mysql_fetch_array($this->dataset);
break;
case "assoc":
return mysql_fetch_assoc($this->dataset);
break;
case "object":
return mysql_fetch_object($this->dataset);
break;
default :
return mysql_fetch_object($this->dataset);
break;
endswitch;
}
Preciso criar um array como resultado da consulta desta maneira.
$smarty->assign("contacts", array(
array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")
));
pra retornar os dados eu uso o while
while ($res = $cliente->retornaDados()) ://
$id = $res->clienteid;
$nome = $res->clientenome;
endwhile;
Alguma sugestao?
Obrigado
Discussão (0)
Carregando comentários...