Welcome Guest, Not a member yet? Register   Sign In
Calling a MySql function
#1

(This post was last modified: 04-28-2019, 09:31 PM by Shawn.)

I have created a function in mysql called NextVal that requires a string parameter and returns an integer.
I tried the following code:
Code:
public function next_value() {
    $ci =& get_instance();
    $sql = 'SELECT nextval(?) as receipt_id';
    $query = $ci->db->query( $sql, array( $this->sequence_name ) );
    return $query->row()->receipt_id;
}

Codeigniter logs the following error:
ERROR - 2019-04-28 19:16:55 --> Query error:  - Invalid query: SELECT nextval('receipt_id_seq') as receipt_id

However, if I paste and run the select statement shown in the error in MySql Workbench it returns the expected integer value under the column name receipt_id
Reply


Messages In This Thread
Calling a MySql function - by Shawn - 04-28-2019, 07:37 PM
RE: Calling a MySql function - by Shawn - 04-28-2019, 09:30 PM
RE: Calling a MySql function - by Shawn - 04-28-2019, 09:40 PM
RE: Calling a MySql function - by InsiteFX - 04-29-2019, 03:50 AM
RE: Calling a MySql function - by Shawn - 04-29-2019, 09:00 PM
RE: Calling a MySql function - by InsiteFX - 04-30-2019, 03:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB