Welcome Guest, Not a member yet? Register   Sign In
Custom Function Call
#1

[eluser]GPC[/eluser]
Hello people, I have the following problem:

I have a function in my database and every time I call it from my model this way:

Code:
$consulta = $this->db->call_function('existe_padre', $rut, $parentesco);

I get the following error:

Quote:A Database Error Occurred

This feature is not available for the database you are using.

So my question is what this error means..

By the way if I call it this way:

Code:
$consulta = $this->db->query("SELECT existe_padre('$rut','$parentesco') as resultado");

I don't get the error.. :-S

Another question.. How can I pass an array to this query

Code:
$consulta = $this->db->query("SELECT existe_padre('$rut','$parentesco') as resultado");


Because basically I wanna do this:

Code:
$consulta = $this->db->call_function('existe_padre', $datos);
[/code]

Where $datos is an array that contains all the information that I want.

Ps: I know my English is not very good so I apologize for that.

Ps1: I'm using mysql 5.1.40
#2

[eluser]danmontgomery[/eluser]
call_function() calls a php function, not a mysql function.

http://ellislab.com/codeigniter/user-gui...ction.html
#3

[eluser]GPC[/eluser]
Wow my bad..

Thanks!

So how can I do what I want..

I was trying to do this..

Code:
$sql = "SELECT existe_padre(?) AS resultado";
        $consulta = $this->db->query($sql, implode(", ",$test));
        return $consulta->row_array();

And I get this error

Quote:Error Number: 1318

Incorrect number of arguments for FUNCTION sysmat.existe_padre; expected 2, got 1

SELECT existe_padre('333333, padre') AS resultado

I know that are the single quotes because I know It will be something like this

Code:
SELECT existe_padre(333333, padre) AS resultado

So how can I do it??
#4

[eluser]danmontgomery[/eluser]
Try:
Code:
$sql = "SELECT existe_padre(?,?) AS resultado";
$consulta = $this->db->query($sql, $test);
#5

[eluser]GPC[/eluser]
That didn't work, but this works!

Code:
$sql = 'SELECT existe_padre(\''.implode('\',\'', $test).'\') AS resultado';
        $consulta = $this->db->query($sql);
        return $consulta->row_array();

Thanks by the way!




Theme © iAndrew 2016 - Forum software by © MyBB