HI, I’m creating a grid connector with MySQL and php using pdo but when I test the code there’s no error but also there’s no info. I don’t want to write the connection sentence every time I want to use a grid so I’m using a class to create th
e connection
This is the table I’m working
This is the connection class called “conexionBD.php”
<php
class Conexion{
public static function crearConexion(){
$host="localhost";
$user="user";
$password="password";
$database="PRUEBAS";
try{
$opciones=array(
PDO::ATTR_PERSISTENT=>true,
PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE=>PDO::FETCH_ASSOC,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'",
PDO::ATTR_EMULATE_PREPARES=>false
);
$conexion= new PDO('mysql:host='.$host.";dbname=".$database,$user,$password,$opciones);
return $conexion;
}catch(PDOException $error){
echo "Error: ".$error->getMessage();
}
}
public static function crearConexionMysql(){
$host="localhost";
$user="user";
$password="password";
$database="PRUEBAS";
$mysqli=mysql_connect($host,$user,$password,$database);
if($mysqli){
return $mysqli;
}else{
echo "Error de conexion ";
}
}
}
?>
And this is the connector file calle “conector_pac.php” using traditional “mysql_connect”
<?php
require_once("./codebase/grid_connector.php");
require_once('conexionBD.php');
$res=Conexion::crearConexionMysql(); //mysql_connect method
mysql_select_db("PRUEBAS"); //I have to write this here, if not the code does not run :(
$conn = new GridConnector($res,"MySQL");
$conn ->render_sql("SELECT id,letra,porci FROM pacientes_pruebas WHERE id>0","id","id,letra,porci");
?>
This is the output (which is correct)
But if Im using pdo method…
<?php
require_once("./codebase/grid_connector.php");
require_once('conexionBD.php');
$res=Conexion::crearConexion(); //pdo method
$conn = new GridConnector($res,"MySQL");
$conn ->render_sql("SELECT id,letra,porci FROM pacientes_pruebas WHERE id>0","id","id,letra,porci");
?>
This is the output… like empty query or something
I tried to import some files that I found on the examples here
https://docs.dhtmlx.com/connector__php__server_side_sample.html
Importing the file db_pdo.php AND changing the initialization of the connector here
$conn = new GridConnector($res,"PDO");// before was $conn = new GridConnector($res,"MySQL");
but when i run the code it simply does not run
I’ll keep trying and thanks for your help and ideas