function delete(TCriteria $criteria) { $sql = new TSqlDelete(); $sql->addEntity($this->entity[0]); $sql->setCriteria($criteria); if ($conn = TTransaction::get()) { $result = $conn->exec($sql->getInstruction()); return $result; } else { throw new Exception('Não há transação ativa!'); } }
function delete(TCriteria $criteria) { $sql = new TSqlDelete(); $sql->setEntity(constant($this->class . '::TABLENAME')); $sql->setCriteria($criteria); if ($conn = TTransaction::get()) { TTransaction::log($sql->getInstruction()); $result = $conn->exec($sql->getInstruction()); return $result; } else { throw new Exception('Não há transação ativa!'); } }
/** * Delete a collection of Active Records from database * @param $criteria An TCriteria object, specifiyng the filters * @return The affected rows */ public function delete(TCriteria $criteria) { // creates a DELETE statement $sql = new TSqlDelete(); $sql->setEntity($this->getEntity()); // assign the criteria to the DELETE statement $sql->setCriteria($criteria); // get the connection of the active transaction if ($conn = TTransaction::get()) { // register the operation in the LOG file TTransaction::log($sql->getInstruction()); // execute the DELETE statement $result = $conn->exec($sql->getInstruction()); return $result; } else { // if there's no active transaction opened throw new Exception(TAdiantiCoreTranslator::translate('No active transactions') . ': ' . __METHOD__ . ' ' . $this->getEntity()); } }
function delete(TCriteria $criteria) { // instancia instrução de DELETE $sql = new TSqlDelete(); $sql->setEntity(constant($this->class . '::TABLENAME')); // atribui o critério passado como parâmetro $sql->setCriteria($criteria); // obtém transação ativa if ($conn = TTransaction::get()) { // registra mensagem de log TTransaction::log($sql->getInstruction()); // executa instrução de DELETE $result = $conn->exec($sql->getInstruction()); return $result; } else { // se não tiver transação, retorna uma exceção throw new Exception('Não há transação ativa!!'); } }
public function delete($id = NULL) { // o ID é o parâmetro ou a propriedade ID $id = $id ? $id : $this->id; // instancia uma instrução de DELETE $sql = new TSqlDelete(); $sql->setEntity($this->getEntity()); // cria critério de seleção de dados $criteria = new TCriteria(); $criteria->add(new TFilter('id', '=', $id)); // define o critério de seleção baseado no ID $sql->setCriteria($criteria); // obtém transação ativa if ($conn = TTransaction::get()) { // faz o log e executa o SQL TTransaction::log($sql->getInstruction()); $result = $conn->exec($sql->getInstruction()); // retorna o resultado return $result; } else { // se não tiver transação, retorna uma exceção throw new Exception('Não há transação ativa!!'); } }
public function deleteCriteria($criteria) { $codigo = $codigo ? $codigo : $this->codigo; // cria instrução SQL $sql = new TSqlDelete(); $sql->addEntity($this->getEntity()); //$criteria = new TCriteria; //$criteria->add(new TFilter('codigo', '=', $codigo)); $sql->setCriteria($criteria); if ($conn = TTransaction::get()) { $result = $conn->exec($sql->getInstruction()); return $result; } else { throw new Exception('Não há transação ativa'); } }
private function deletePortifolio() { try { foreach ($this->collectionCodigo as $codigo) { //RECUPERA CONEXAO BANCO DE DADOS TTransaction2::open('my_bd_site'); //TABELA exposition_gallery $criteria = new TCriteria(); $criteria->add(new TFilter(' codigo ', ' = ', "{$codigo}")); // instancia a instrução de SELECT $sql = new TSqlDelete(); $sql->setEntity('portifolio'); //Define criterio de Exclusao $sql->setCriteria($criteria); //Obtem transação ativa if ($conn = TTransaction2::get()) { //Faz o log e executa o SQL TTransaction2::log($sql->getInstruction()); $result = $conn->exec($sql->getInstruction()); } TTransaction2::close(); } return true; } catch (Exception $e) { return false; } }
/** * Delete an Active Record object from the database * @param [$id] The Object ID * @exception Exception if there's no active transaction opened */ public function delete($id = NULL) { // discover the primary key name $pk = $this->getPrimaryKey(); // if the user has not passed the ID, take the object ID $id = $id ? $id : $this->{$pk}; // creates a DELETE instruction $sql = new TSqlDelete(); $sql->setEntity($this->getEntity()); // creates a select criteria $criteria = new TCriteria(); $criteria->add(new TFilter($pk, '=', $id)); // assign the criteria to the delete instruction $sql->setCriteria($criteria); // get the connection of the active transaction if ($conn = TTransaction::get()) { // register the operation in the LOG file TTransaction::log($sql->getInstruction()); $result = $conn->exec($sql->getInstruction()); // return the result of the exec() method return $result; } else { // if there's no active transaction opened throw new Exception(TAdiantiCoreTranslator::translate('No active transactions') . ': ' . __METHOD__ . ' ' . $this->getEntity()); } }
/** * Método delete() * Exclui um conjunto de objetos (collection) da base de dados através de um critério de seleção * * @access public * @param $criteria Objeto do tipo TCriteria * @throws Exception Não há transação ativa * @return void */ function delete(TCriteria $criteria) { $sql = new TSqlDelete(); $sql->addEntity($this->entity[0]); $sql->setCriteria($criteria); //RECUPERA CONEXAO BANCO DE DADOS TTransaction::open('my_bd_site'); if ($conn = TTransaction::get()) { $result = $conn->exec($sql->getInstruction()); TTransaction::close(); return $result; } else { throw new Exception('Não há transação ativa!'); } }
/** * Método deleteCriteria * Exclui um objeto da base de dados através de um Código * * @access public * @param $criteria Critério de seleção * @throws Exception Não há transação ativa * @return boolean Resultado da operação de delete */ public function deleteCriteria($criteria) { $codigo = $codigo ? $codigo : $this->codigo; // cria instrução SQL $sql = new TSqlDelete(); $sql->addEntity($this->getEntity()); //$criteria = new TCriteria; //$criteria->add('codigo', '=', $codigo); $sql->setCriteria($criteria); //RECUPERA CONEXAO BANCO DE DADOS TTransaction::open('my_bd_site'); if ($conn = TTransaction::get()) { $result = $conn->exec($sql->getInstruction()); TTransaction::close(); return $result; } else { throw new Exception('Não há transação ativa'); } }
public function delete($id = NULL) { $id = $id ? $id : $this->id; // cria instrução SQL $sql = new TSqlDelete(); $sql->setEntity($this->getEntity()); $criteria = new TCriteria(); $criteria->add(new TFilter('id', '=', $id)); $sql->setCriteria($criteria); if ($conn = TTransaction::get()) { TTransaction::log($sql->getInstruction()); $result = $conn->exec($sql->getInstruction()); return $result; } else { throw new Exception('Não há transação ativa'); } }
/** * Delete an Active Record object from the database * @param [$id] The Object ID * @exception Exception if there's no active transaction opened */ public function delete($id = NULL) { $class = get_class($this); // discover the primary key name $pk = $this->getPrimaryKey(); // if the user has not passed the ID, take the object ID $id = $id ? $id : $this->{$pk}; // creates a DELETE instruction $sql = new TSqlDelete(); $sql->setEntity($this->getEntity()); // creates a select criteria $criteria = new TCriteria(); $criteria->add(new TFilter($pk, '=', $id)); // assign the criteria to the delete instruction $sql->setCriteria($criteria); // get the connection of the active transaction if ($conn = TTransaction::get()) { // register the operation in the LOG file TTransaction::log($sql->getInstruction()); $result = $conn->exec($sql->getInstruction()); unset($this->data); if (defined("{$class}::OBJECTCACHE") and constant("{$class}::OBJECTCACHE") == TRUE and extension_loaded('apc')) { apc_delete($class . '[' . $id . ']'); TTransaction::log($class . '[' . $id . '] deleted from cache'); } // return the result of the exec() method return $result; } else { // if there's no active transaction opened throw new Exception(TAdiantiCoreTranslator::translate('No active transactions') . ': ' . __METHOD__ . ' ' . $this->getEntity()); } }
<?php /* Função autoload() Carrega uma class quando ele é necessária, ou seja, quando ela é instanciada pela primeira vez */ function __autoload($classe) { if (file_exists("app.ado/{$classe}.class.php")) { include_once "app.ado/{$classe}.class.php"; } } //Criar critéria de seleção e dados $criteria = new TCriteria(); $criteria->add(new TFilter('id', '=', '3')); //Criar Instrução DELETE $sql = new TSqlDelete(); //definir o nome da entidade $sql->setEntity('aluno'); // Definir Critério de seleção de dado $sql->setCriteria($criteria); //Processar a intrução SQL echo $sql->getInstruction(); echo "<br>\n";