Made PDO connection successfully but arrays empty

Made PDO connection successfully but arrays empty

boudgaboudga Posts: 19Questions: 4Answers: 0

So I believe I have made a successful PDO connection to MSSQL server but when I run the following I get empty arrays:

Editor::inst( $db, 'ALLPRODUCTS', 'nseq' )
->fields(
Field::inst( 'citemno' ),
Field::inst( 'cdescript' ),
Field::inst( 'cmanufacturer' ),
Field::inst( 'cproducttype1' ),
Field::inst( 'cproducttype2' ),
Field::inst( 'quantity' ),
Field::inst( 'cuom' ),
Field::inst( 'price' ),
Field::inst( 'subtotal' )
)
->process( $_POST )
->json();

Response: {"data":[],"options":[],"files":[]}

Answers

  • joseoliveiraborlasjoseoliveiraborlas Posts: 80Questions: 8Answers: 3

    Check again the connection with the database, table name and if any error.log appeared on the server.

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    If you get a response like that, then it suggests that the ALLPRODUCTS table on the connected database is empty.

    If there was a connection error, then it would give such an error. Can you confirm you are connecting to a database with data in that table by querying it directly?

    Perhaps try:

    $res = $db->select('ALLPRODUCTS')->fetchAll();
    
    print_r($res);
    

    Allan

Sign In or Register to comment.