Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

250
Vistas
How to check if rows exist PDO PHP?

I'm learning PHP PDO and I need some help with codes. I have 2 Questions today.

First Question: How can I check if row exist in table with Network_Code and Niche, if there is column with same ID to proceed, but with same ID and Niche to die message.

    $network_code = $_GET[ 'ID' ];
    $Niche      = $_GET[ 'Niche' ];
    $sql = "INSERT INTO `affiliates` (ID, Niche, Language, lockerURL, Network_Code, Google_ID) VALUES (NULL, '$Niche', '$Language', '$domain', '$network_code ', '$Google_ID')";

    $query = $pdo->prepare( $sql );
    $query->execute();

Second Question: Is there any other way that I can use: $system_default[ 0 ]->column because I think that is wrong way, so I need something like this: $system_default->column class default_system {

    function __construct( $pdo ) {

        $this->pdo = $pdo;

    }

    function getData() {

        $ID     = $_GET[ 'id' ];

        $Niche  = "clash-clans";

        $query = $this->pdo->prepare( "SELECT * FROM `affiliates` WHERE `Network_Code` = '$ID' AND `Niche` = '$Niche'" ); 
        $query->execute();  

        return $query->fetchAll( PDO::FETCH_OBJ ); // Return an Array of objects

    }

}   

$db_system = new default_system( $pdo );
$system_default = $db_system->getData();

echo $system_default[ 0 ]->lockerURL;
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Below example for First Question, you can try to solve your problem certain ways below is example of it. you can read more about pdo from here

$query=$dbh->prepare("SELECT secret FROM users WHERE username=:param");
$query->bindParam(':param', $param);
$query->execute();
$result = $query -> fetch();
print_r($result);

For second issue

echo $system_default['lockerURL'];

and remove echo $system_default[ 0 ]->lockerURL; line

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda