Diferencia entre revisiones de «Usuario:ManuelRomero/php»
De WikiEducator
| Línea 8: | Línea 8: | ||
https://medium.com/the-era-of-apis/how-to-use-an-api-with-php-complete-beginners-guide-4283f9f8d9b3 | https://medium.com/the-era-of-apis/how-to-use-an-api-with-php-complete-beginners-guide-4283f9f8d9b3 | ||
https://docs.rapidapi.com/docs/api-pricing | https://docs.rapidapi.com/docs/api-pricing | ||
| + | ===Para bind_param=== | ||
| + | *Usar el método como una llamada callback usando la función del sistema ''''call_user_func'''' | ||
| + | *https://www.php.net/manual/es/function.call-user-func-array.php | ||
| + | <source lang=php> | ||
| + | $con = new mysqli(...); | ||
| + | $stmt = $con->stmt_init (); | ||
| + | $sentencia = "Select * from tabla where c1=?, and c2=?"; | ||
| + | $stmt->prepare($sentencia); | ||
| + | $tipos ="ss"; | ||
| + | $parametros =[$tipos, $v1, $v2]; | ||
| + | if ( call_user_func_array( [$stmt, 'bind_param'], ( $parametros ) ) === false ) | ||
| + | echo "OK"; | ||
| + | else | ||
| + | echo "No ok!!"; | ||
| + | </source> | ||
| + | ===Usar el operador de desempaquetado o splat operator ... === | ||
| + | https://www.php.net/manual/en/migration56.new-features.php#migration56.new-features.splat | ||
| + | <source lang=php> | ||
| + | $con = new mysqli(...); | ||
| + | $stmt = $con->stmt_init (); | ||
| + | $sentencia = "Select * from tabla where c1=?, and c2=?"; | ||
| + | $stmt->prepare($sentencia); | ||
| + | $tipos ="ss"; | ||
| + | $parametros =[$v1, $v2]; | ||
| + | $stmt->bind_param($tipos, ...&$parametros) | ||
| + | </source> | ||
Revisión de 17:09 15 abr 2020
API
https://medium.com/the-era-of-apis/how-to-use-an-api-with-php-complete-beginners-guide-4283f9f8d9b3 https://docs.rapidapi.com/docs/api-pricing
Para bind_param
- Usar el método como una llamada callback usando la función del sistema 'call_user_func'
- https://www.php.net/manual/es/function.call-user-func-array.php
$con = new mysqli(...); $stmt = $con->stmt_init (); $sentencia = "Select * from tabla where c1=?, and c2=?"; $stmt->prepare($sentencia); $tipos ="ss"; $parametros =[$tipos, $v1, $v2]; if ( call_user_func_array( [$stmt, 'bind_param'], ( $parametros ) ) === false ) echo "OK"; else echo "No ok!!";
Usar el operador de desempaquetado o splat operator ...
https://www.php.net/manual/en/migration56.new-features.php#migration56.new-features.splat
$con = new mysqli(...); $stmt = $con->stmt_init (); $sentencia = "Select * from tabla where c1=?, and c2=?"; $stmt->prepare($sentencia); $tipos ="ss"; $parametros =[$v1, $v2]; $stmt->bind_param($tipos, ...&$parametros)