Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/12/2014, 18:01
guepadot
 
Fecha de Ingreso: mayo-2008
Mensajes: 3
Antigüedad: 16 años
Puntos: 0
Pregunta consulta desde php a mysql modo esclavo

cordial saludo,

por tema de rendimiento configure la base de datos que tengo en mysql de modo master / slave, la que me esta funcionando correctamente, cuando hago insert me lo graba en el master y en esclavo.

pero solicito ayuda para saber como puedo hacer la consulta a la base de datos, pero directamente a la esclavo,

replica.php
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_replica = "192.168.10.233";
$database_replica = "inventariomb";
$username_replica = "root";
$password_replica = "";
$replica = mysql_pconnect($hostname_replica, $username_replica, $password_replica) or trigger_error(mysql_error(),E_USER_ERROR);
?>

consulta.php
<?php require_once('../../../Connections/replica.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_conexion, $conexion);
$query_Recordset1 = "SELECT * FROM articulo";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $conexion) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>

<body>

<table border="1">
<tr>
<td>RefArticulo</td>
<td>DescripcionArticulo</td>
<td>UnMedidaArticulo</td>
<td>IdUsuario_Usuario</td>
<td>IdEstado_Estado</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['RefArticulo']; ?></td>
<td><?php echo $row_Recordset1['DescripcionArticulo']; ?></td>
<td><?php echo $row_Recordset1['UnMedidaArticulo']; ?></td>
<td><?php echo $row_Recordset1['IdUsuario_Usuario']; ?></td>
<td><?php echo $row_Recordset1['IdEstado_Estado']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
Registros <?php echo ($startRow_Recordset1 + 1) ?> a <?php echo min($startRow_Recordset1 + $maxRows_Recordset1, $totalRows_Recordset1) ?> de <?php echo $totalRows_Recordset1 ?>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

gracias