# mysql-* versus db_* statements

- Thread: https://externals.io/message/24214
- Original archive: https://news-web.php.net/php.internals/24214
- Started by j.kuehne@sign-tronic.ch on 2006-06-26T07:10:03+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #24214 — j.kuehne@sign-tronic.ch — 2006-06-26T07:10:03+00:00

URL: https://externals.io/message/24214#24214

require_once "DB.php";                         
require_once "knowledge.inc";  
require_once "template-new.inc";  
         

function setupQuery($search_eb)
{
   // Show the wines stocked at the winestore that match
   // the search criteria
   
  $query = "SELECT *
             FROM knowledge_db
             WHERE MATCH (autor,problem) AGAINST ('$search_eb')
             OR id = ('$search_eb') 
             OR autor = ('$search_eb')  
             OR stichwort = ('$search_eb')
             OR date_new = ('$search_eb')
             OR anlage = ('$search_eb')";
             
   // Add region_name restriction if they've selected anything
  
  //$query .= "ORDER BY data_new";
   return ($query);
}

error_reporting(E_ALL);


// Show the user the knowledge that match their query
function showKnowledges($connection, &$template)
{
 

 // Produce a heading for the top of the page
 
 global $dsn;
 
   
 $template->setCurrentBlock();
 
 $template->setVariable("SUCH-KRITERIUM","Such-Kriterium: {$_SESSION["searchFormVars"]["search_eb"]}");  
 
 $browseString = "search_eb=" . urlencode($_SESSION["searchFormVars"]["search_eb"]);    
   
 $search = ($_SESSION["searchFormVars"]["search_eb"]);
 
 $link = mysql_connect("localhost", "root", "040573");
   
 $template->parseCurrentBlock();
 


mysql_select_db("knowledge", $link);

// Encode the search parameters for embedding in links to other pages 
// $connection = DB::connect($dsn, true);
$query = setupQuery($_SESSION["searchFormVars"]["search_eb"]);     
//$result = $connection->query($query);
//var_dump ($query);
$result=@mysql_query($query);
   
...


why I could not use the DB statement $result = $connection->query($query) instead of the mysql statement $result=@mysql_query($query); Further on, the same situation appears in the code, which looks like:


 for ( $rowCounter = 0;
            ($rowCounter < SEARCH_ROWS) &&
            (( $rowCounter + $_SESSION["searchFormVars"]["offset"]) <  mysql_num_rows($result))  && 
            ($row =  mysql_fetch_array($result));
           //($row =mysql_fetch_row($_SESSION["searchFormVars"]["offset"]+$rowCounter));
           //   ($row = & $result->fetchRow(DB_FETCHMODE_ASSOC, $_SESSION["searchFormVars"]["offset"]+$rowCounter));
           $rowCounter++)


I could not use the DB statement ($row = & $result->fetchRow(DB_FETCHMODE_ASSOC, $_SESSION["searchFormVars"]["offset"]+$rowCounter)); 
instead of the mysql code ($row =  mysql_fetch_array($result)). But in that case, there is not the same meaning between the msyql and DB statement. However, I need the DB assignation for faultless work. What can I do?

best reagards, Georg

---

## #24215 — Antony Dovgal — 2006-06-26T07:18:11+00:00

URL: https://externals.io/message/24214#24215 · In reply to: #24214

Please user php-general@lists.php.net for such questions.
Thank you.


> require_once "DB.php";                         
> require_once "knowledge.inc";  
> require_once "template-new.inc";  
>          
> 
> function setupQuery($search_eb)
> {
>    // Show the wines stocked at the winestore that match
>    // the search criteria
>    
>   $query = "SELECT *
>              FROM knowledge_db
>              WHERE MATCH (autor,problem) AGAINST ('$search_eb')
>              OR id = ('$search_eb') 
>              OR autor = ('$search_eb')  
>              OR stichwort = ('$search_eb')
>              OR date_new = ('$search_eb')
>              OR anlage = ('$search_eb')";
>              
>    // Add region_name restriction if they've selected anything
>   
>   //$query .= "ORDER BY data_new";
>    return ($query);
> }
> 
> error_reporting(E_ALL);
> 
> 
> // Show the user the knowledge that match their query
> function showKnowledges($connection, &$template)
> {
>  
> 
>  // Produce a heading for the top of the page
>  
>  global $dsn;
>  
>    
>  $template->setCurrentBlock();
>  
>  $template->setVariable("SUCH-KRITERIUM","Such-Kriterium: {$_SESSION["searchFormVars"]["search_eb"]}");  
>  
>  $browseString = "search_eb=" . urlencode($_SESSION["searchFormVars"]["search_eb"]);    
>    
>  $search = ($_SESSION["searchFormVars"]["search_eb"]);
>  
>  $link = mysql_connect("localhost", "root", "040573");
>    
>  $template->parseCurrentBlock();
>  
> 
> 
> mysql_select_db("knowledge", $link);
> 
> // Encode the search parameters for embedding in links to other pages 
> // $connection = DB::connect($dsn, true);
> $query = setupQuery($_SESSION["searchFormVars"]["search_eb"]);     
> //$result = $connection->query($query);
> //var_dump ($query);
> $result=@mysql_query($query);
>    
> ...
> 
> 
> why I could not use the DB statement $result = $connection->query($query) instead of the mysql statement $result=@mysql_query($query); Further on, the same situation appears in the code, which looks like:
> 
> 
>  for ( $rowCounter = 0;
>             ($rowCounter < SEARCH_ROWS) &&
>             (( $rowCounter + $_SESSION["searchFormVars"]["offset"]) <  mysql_num_rows($result))  && 
>             ($row =  mysql_fetch_array($result));
>            //($row =mysql_fetch_row($_SESSION["searchFormVars"]["offset"]+$rowCounter));
>            //   ($row = & $result->fetchRow(DB_FETCHMODE_ASSOC, $_SESSION["searchFormVars"]["offset"]+$rowCounter));
>            $rowCounter++)
> 
> 
> I could not use the DB statement ($row = & $result->fetchRow(DB_FETCHMODE_ASSOC, $_SESSION["searchFormVars"]["offset"]+$rowCounter)); 
> instead of the mysql code ($row =  mysql_fetch_array($result)). But in that case, there is not the same meaning between the msyql and DB statement. However, I need the DB assignation for faultless work. What can I do?
> 
> best reagards, Georg
> 
>  


-- 
Wbr, 
Antony Dovgal
