Querys with udfs in where

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
rubeno
Forum Newbie
Posts: 1
Joined: Fri Dec 13, 2002 2:06 pm

Querys with udfs in where

Post by rubeno »

Hi, i have a problem with the next source:

<?php
function Funcion1($pParametro)
{ $Con1 = odbc_connect("Datos","","");
$Query = "SELECT dato FROM tabla1 WHERE id=".$pParametro;
$Resul = @odbc_exec($Con1,$Query);
// @odbc_result_all($Resul, "BGCOLOR='#AAFFAA' border=3 width=30%");
return @odbc_result($Resul,1);
odbc_close($Con1);
};

$Conn = odbc_connect("Datos","","");
$Consulta = "SELECT * FROM tabla WHERE id=13875 and campo1=Funcion1(1300)";
$Resultado = @odbc_exec($Conn,$Consulta);
@odbc_result_all($Resultado, "BGCOLOR='#AAFFAA' border=3 width=30%");
odbc_close($Conn);
?>

I connect with Visual Fox tables via ODBC, and I execute the script and nothing is returned, i think that the function Funcion1() does not execute int the query, but i test the same function and it is working OK. I can't to migrate to another DataBase (MySQL for example).
If there's somebody who understanding me, please respond, and sorry for my english.

Rubén.
User avatar
TheTestUser
Forum Newbie
Posts: 9
Joined: Sat Dec 14, 2002 9:25 pm

Post by TheTestUser »

For interoperability between databases, I would suggest using a database abstraction class.
In this way, your code will not depend on any one type of database and can be used on MySQL, PostGres, Oracle, ect...

At least that's the theory. In reality, different database deal with things differently or don't support the features you come to expect from working with one databas for a long time.

Do a google search on database abstraction and see with what you come up with. I found an interesting, though somewhat lacking, article at PHPBuilder. I thought I had seen the devnetwork have an article explaining it in more detail but I couldn't find it.
Post Reply