include "./DPManager-Basic.php"; $cliente = array(); // Arreglo asociativo $cliente['id_cliente'] = 1; $cliente['nombre'] = "'Héctor'"; $cliente['paterno'] = "'Hérnandez'"; $cliente['materno'] = "'Rivera'"; // UPDATE tabla SET [campo = '1'[, campo2 = '2']] $lstGetSetToUpdate = DPManager::buildDatosToUpdate($cliente); echo "<hr />"; echo $lstGetSetToUpdate; echo "<hr />"; // UPDATE tabla SET campo = '1', campo2 = '2', campo3 = '4' // WHERE campo1 = 'x' $lstUpdateQuery = DPManager::buildUpdateQuery("tabla", $lstGetSetToUpdate, "id_cliente = 3"); echo "<hr />"; echo $lstUpdateQuery; echo "<hr />"; $lstInsertQuery = DPManager::buildInsertQuery($cliente, "tabla"); echo "<hr />"; echo $lstInsertQuery; echo "<hr />"; // select * from tabla order by nombre desc $lstSelectQuery = DPManager::buildSelectQuery("nombre, paterno" . ", concat_ws(',', nombre, paterno) as completo", "tabla", false, false, "nombre", "asc"); echo "<hr />"; echo $lstSelectQuery; echo "<hr />"; // select * from tabla order by nombre desc $lstSelectGroupQuery = DPManager::buildSelectQuery("count(*)", "tabla", " nombre like '%i%' "); echo "<hr />";
* INSERT Query Example 1 * * Output : INSERT INTO NOMBRE_TABLA ( CAMPO1,CAMPO2,CAMPO3) VALUES ( 'Valor 1' , 'Valor 2' , 'Valor 3' ) * */ $lstInsertQuery1 = DPManager::buildInsertQuery($larFields, "NOMBRE_TABLA"); echo "<h1>Build Simple Insert Data From Params array type and table name</h1>"; echo $lstInsertQuery1; /** * UPDATE Query Example 1 * Para este ejemplo, necesitamos construir el SET con DPManager::buildDatosToUpdate($larFields); * * Output : UPDATE NOMBRE_TABLA SET CAMPO1 = 'Valor 1' ,CAMPO2 = 'Valor 2' ,CAMPO3 = 'Valor 3' WHERE CAMPO = 'valor' * */ $lstUpdateQuery1 = DPManager::buildUpdateQuery("NOMBRE_TABLA", $lstUpdateQuery, "CAMPO = 'valor' "); echo "<h1>Build Simple Update From Params array type, table name and condition to affect rows</h1>"; echo $lstUpdateQuery1; /** * Poder iterar resultados de base de datos, Object u Array aplicando un metodo * de regreso * @param array */ $array = array(array(1, 2), array(3, 4)); $result = DPManager::iteraRecord($array, function () { $row = func_get_args(); $uno = $row[0] . "UNO"; $dos = $row[1] . "DOS"; return array($uno, $dos); }); echo "<h1>Aplicación de método anonimo a cada uno " . "de los elementos del objeto o arreglo</h1>";