function deleteServicio($id) { $sql = "DELETE FROM servicios WHERE idx=:id"; try { $db = getCnxn(); $stmt = $db->prepare($sql); $stmt->bindParam("id", $id); $stmt->execute(); $db = null; } catch (PDOException $e) { echo '{"error":{"text":' . $e->getMessage() . '}}'; } }
function validaEmpresaUsuario($user_id, $empresa_id = null, $data = true) { if ($empresa_id == null) { $arrArgs = array($user_id); $sql = "SELECT ue.idx_empresa,e.nombre,e.imagen_logo,e.rfc,ue.createdAt FROM usuario_empresa AS ue INNER JOIN empresa AS e ON e.idx=ue.idx_empresa WHERE ue.idx_usuario=? ORDER BY e.nombre;"; } else { $arrArgs = array($user_id, $empresa_id); $sql = "SELECT ue.idx_empresa,e.nombre,e.imagen_logo,e.rfc,ue.createdAt FROM usuario_empresa AS ue INNER JOIN empresa AS e ON e.idx=ue.idx_empresa WHERE ue.idx_usuario=? AND ue.idx_empresa=?;"; } $db = getCnxn(); $rs = $db->query($sql, $arrArgs); if ($rs === false) { return false; } $db = null; if (!$data) { $data_rows = intval(count($rs)); return $data_rows > 0 ? true : false; } return $rs; }