Skip to content

Commit

Permalink
atualizacao
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobmorais committed Feb 23, 2023
1 parent 0f5d47d commit 9a2714b
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/Crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Classe abastrada para fazer ligação entre o banco e aplicação
*
* @author Bruno Morais <brunomoraisti@gmail.com>
* @copyright GPL © 2022, bmorais.com
* @copyright GPL © 2023, bmorais.com
* @package bmorais\database
* @subpackage class
* @access private
Expand Down Expand Up @@ -56,6 +56,24 @@ public function insert(string $fields, array $values = null, $debug = false)
return true;
}

/**
* @param object $object
* @return bool|null
*/
public function insertObject(object $object)
{
$args = [];
$params = [];
foreach ($object as $chave => $valor) {
if ($valor != NULL) {
array_push($args, $chave);
array_push($params, $valor);
}
}
$args = implode(',', $args);
return $this->insert($args, $params);
}

/**
* @param array $params
* @return bool
Expand Down Expand Up @@ -110,6 +128,25 @@ public function update(string $fields, array $values = null, string $where = nul
return true;
}


/**
* @param object $object
* @param string $where
* @return bool|null
*/
public function updateObject(object $object, string $where){
$args = [];
$params = [];
foreach ($object as $chave => $valor) {
if ($valor != NULL) {
array_push($args, $chave);
array_push($params, $valor);
}
}
$args = implode(',', $args);
return $this->update($args, $params, $where);
}

/**
* @param array $params
* @param string $where
Expand Down

0 comments on commit 9a2714b

Please sign in to comment.