We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33392
    • 8 Posts
    Hi fist step into xpdo
    this example  query work show result
    
    <?php
    $dsn = 'mysql:host=localhost;dbname=nse_dbo;port=3306;charset=utf-8';
    $xpdo = new xPDO($dsn,'root','');
    echo $o=($xpdo->connect()) ? 'Connected' : 'Not Connected';
    $xpdo->addPackage('nsx','/Modx3/core/components/nsx/model','nse_');
    
    /// aqui se conecta es un ejemplo de simple query .
    $query = $xpdo->query("SELECT * FROM `nse_ciudad`");
    
    	if ($query) {
    		while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    			print_r($row );
    	}
    	}	else { echo "YOU SUCK at Programming!";}
    echo"try8";
    
    


    ConnectedArray ( [IdCiudad] => 3 [Ciudad] => Antofagasta [Reguion] => Region de Antofagasta ) Array ( [IdCiudad] => 1 [Ciudad] => Arica [Reguion] => Region de Arica y Parinacota ) Array ( [IdCiudad] => 4 [Ciudad] => Calama [Reguion] => Region de Antofagasta ) Array ( [IdCiudad] => 5 [Ciudad] => Copiapo [Reguion] => Region de Atacama ) Array ( [IdCiudad] => 2 [Ciudad] => Iquique [Reguion] => RegionTarapac� ) Array ( [IdCiudad] => 7 [Ciudad] => Serena & Coquimbo [Reguion] => Region de Coquimbo ) Array ( [IdCiudad] => 6 [Ciudad] => Vallenar [Reguion] => Region de Atacama ) try8Connected

      but this not show nothing,can not be wrong
    $dsn = 'mysql:host=localhost;dbname=nse_dbo;port=3306;charset=utf-8';
    $xpdo = new xPDO($dsn,'root','');
    echo $o=($xpdo->connect()) ? 'Connected' : 'Not Connected';
    $xpdo->addPackage('nsx','/Modx3/core/components/nsx/model','nse_');
    
    /// resultados .
    $query = $xpdo->query("SELECT * FROM `nse_ciudad`");
    foreach ($xpdo->query($query) as $row) {
      echo $row['Reguion'] . ", " . $row['Ciudad'] . "
    \n";
    


    if you can help me if I'm in a right way [ed. note: zatanax last edited this post 15 years, 1 month ago.]
      • 33968
      • 863 Posts
      Try this:
      $query = $xpdo->query("SELECT * FROM `nse_ciudad`");
      foreach ($query as $row) {
        echo $row['Reguion'] . ", " . $row['Ciudad'] . "<br>\n";
      
        • 33392
        • 8 Posts
        thanks lucas work laugh laugh laugh
        $query = $xpdo->query("SELECT * FROM `nse_ciudad`");
        foreach ($query as $row)
         {
          echo $row['Reguion'] . ", " . $row['Ciudad'] . "<br>\n";
        }