0

Kohana is a php framework. this is the documention . how to call procedure in this framework. i have searched and questions about this question. like : insert_id in Kohana 3

this is my code :

$conn = Database::instance();       
$queryStr = "call sp_createUser('$nick_name','$email','$password','127.0.0.1')";
$query = DB::query(Database::SELECT, $queryStr);
$query->execute($conn);

but there's some exception..

Database_Exception [ 1312 ]: PROCEDURE sp_createUser can't return a result set in the given context [ call sp_createUser('1','1','1','127.0.0.1') ]

it seems that something wrong with the db connection..

how can i fix it ...ask some help..

Community
  • 1
  • 1

2 Answers2

0

Use $query->compile(Database::instance); before querying to inspect your query string and find it's bugs.

Also give us your PROCEDURE body. It semms like PROCEDURE returns data in incompatible format to Kohana.

Is your $query->compile(Database::instance); return string executes in mysql directly?

s.webbandit
  • 16,332
  • 16
  • 58
  • 82
  • call sp_createUser('1','1','1','127.0.0.1') ,it can execute successfully in db .so nothing wrong with the query string. – user1335597 Apr 16 '12 at 06:34
  • What module do you use in PHP to work with MySQL? mod_mysql or mod_mysqli? Working with stored procedures requires mod_mysqli. – s.webbandit Apr 16 '12 at 06:42
  • mod_mysql ,here's the framework documention:http://kohanaframework.org/3.1/guide/database/query/builder – user1335597 Apr 16 '12 at 06:50
  • i think i find out the problem . i try to create a random id for each user in the procedure , then i use "select account_id" return the account directly.i comment this ,the exception is gone. – user1335597 Apr 16 '12 at 07:08
-2

try replacing call with SELECT...

$queryStr = "SELECT sp_createUser('$nick_name','$email','$password','127.0.0.1')";
David Chan
  • 7,347
  • 1
  • 28
  • 49