/** * <b>Exe Read:</b> Executa uma leitura simplificada com Prepared Statments. Basta informar o nome da tabela, * os termos da seleção e uma analize em cadeia (ParseString) para executar. * @param STRING $Tabela = Nome da tabela * @param STRING $Termos = WHERE | ORDER | LIMIT :limit | OFFSET :offset * @param STRING $ParseString = link={$link}&link2={$link2} * @return Conn */ public function ExeRead($Tabela, $Termos = null, $Places = null) { $this->Places = (array) $Places; $this->Select = "SELECT * FROM " . parent::getTableName($Tabela) . " {$Termos}"; $this->Execute(); return $this; }
/** * <b>ExeCreate:</b> Executa um cadastro simplificado no banco de dados utilizando prepared statements. * Basta informar o nome da tabela e um array atribuitivo com nome da coluna e valor! * * @param STRING $Tabela = Informe o nome da tabela no banco! * @param ARRAY $Dados = Informe um array atribuitivo. ( Nome Da Coluna => Valor ). * @return \Create */ public function ExeCreate($Tabela, array $Dados) { $this->Tabela = (string) Conn::getTableName($Tabela); $this->Dados = self::format_values($Tabela, $Dados); if (empty($this->Dados)) { throw new Exception("A array de dados está vazia. Tentativa de salvar dados na tabela `{$Tabela}` não foi concluída."); } $this->getSyntax(); $this->Execute(); return $this; }
function optEstados($estado = '', $titleUf = 'title') { $html = ""; $read = new Read(); $read->FullRead("\r\n\t SELECT *, IF(:estado LIKE a.title OR :estado = a.uf OR :estado = a.id, 1, 0) AS `selected`\r\n\t FROM `" . Conn::getTableName('estados') . "` AS a\r\n\t ORDER BY a.title ASC, a.uf ASC\r\n\t ", array('estado' => $estado)); foreach ($read->getResult() as $v) { $html .= formSelectOption($titleUf == 'uf' ? $v['uf'] : $v['title'], $v['id'], $v['selected'] ? true : false); } return $html; }