sql query in 7.4.1

i am using 7.4.1, but for some reason i cant get a simple sql query to work. It is a duplicate from an earlier version of dolphin - in which it does work, but not working in the latest version. Any help would be greatly appreciated.

 

Thanks in advance.

 

$Products = mysql_query("SELECT * FROM oc_product");
        while ($row = mysql_fetch_array($Products)) {
        $product_id = $row["product_id"];   
        echo ' ' . $product_id . ' ' ;
        }

caredesign.net
Quote · 6d ago

The functions mysql_query and mysql_fetch_array are depreciated in php7.

Dolphin has switched to pdo functions for compatibility with php 7. So my guess is because previous versions of dolphin did use those functions your using, they worked for you because dolphin already had a open resource to the database. But now the resource is different due to the use of the pdo functions.

You should be using the built in dolphin database functions anyway. Try this instead.

$Products = $GLOBALS['MySQL']->getAll("SELECT * FROM oc_product");
foreach ($Products as $id => $value) {
    $product_id = $value["product_id"];
    echo ' ' . $product_id . ' ';
}

https://www.deanbassett.com
Quote · 6d ago

 i am using php 5.4, though not php 7

The functions mysql_query and mysql_fetch_array are depreciated in php7.

Dolphin has switched to pdo functions for compatibility with php 7. So my guess is because previous versions of dolphin did use those functions your using, they worked for you because dolphin already had a open resource to the database. But now the resource is different due to the use of the pdo functions.

You should be using the built in dolphin database functions anyway. Try this instead.

$Products = $GLOBALS['MySQL']->getAll("SELECT * FROM oc_product");
foreach ($Products as $id => $value) {
    $product_id = $value["product_id"];
    echo ' ' . $product_id . ' ';
}

 

caredesign.net
Quote · 6d ago

Does not matter. Dolphin no longer uses those functions, so the most likely reason they no longer work for you is because your relying on dolphins open connection to the database which works differently now.

As i stated, you should be using dolphins native database functions.

 

https://www.deanbassett.com
Quote · 6d ago

 do you happen to know what the global function is to count rows of a query?

Does not matter. Dolphin no longer uses those functions, so the most likely reason they no longer work for you is because your relying on dolphins open connection to the database which works differently now.

As i stated, you should be using dolphins native database functions.

 

 

caredesign.net
Quote · 6d ago
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.