Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-28-2008, 05:09 AM
Junior Member
 
Join Date: Mar 2008
Posts: 2
Default Facing problem in fetching record from database using Zend Mysqli

Hi,

I am new to Zend. I am using Zend 1.5 and Php 5.2.0. I am facing problem while I am trying to get the records from the database. I am using stored procedures with Mysqli.

My code is:-

In config file, I wrote:-

; Database Settings
db.adapter = Mysqli
db.dbname = test
db.hostname = localhost
db.username = root
db.password = test

In bootstrap file, I wrote:-
// setup database
$params = array(
'host' => $config->db->hostname,
'username' => $config->db->username,
'password' => $config->db->password,
'dbname' => $config->db->dbname,
'driver_options' => ''
);

$db = Zend_Db::factory($config->db->adapter,$params);
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('db', $db);

In the main model file where I am trying to fetch the record, I just called write these statements:-
/*
* Open the database registry
*/
$db = Zend_Registry::get('db');

$stmt = $db->prepare("call uspSelectUsers()");
$stmt->execute();
$result = $stmt->fetch();

It gives me warning messages and doesn't give any result.

Warning: Invalid argument supplied for foreach() in /home/test/public_html/test/library/Zend/Db/Statement/Mysqli.php on line 289

Warning: array_combine() expects parameter 1 to be array, null given in /home/test/public_html/test/library/Zend/Db/Statement/Mysqli.php on line 299

When I print the mysql error, there is nothing in the string means there is no mysql error.

When I wrote the complete sql statement in the prepare statement rather than calling a stored procedure, I got the results. But I didn't get any result by using stored procedure.

Also, the interesting thing is when I use the same to insert a record in the table by using stored proceudre, the record inserted successfully. To insert a record I just used the simple query in my model file

/*
* Open the database registry
*/
$db = Zend_Registry::get('db');

$stmt = $db->prepare("call uspInsertUsers($name, $email)");
$stmt->execute();

The record inserted successfully in the table.

So, please help me to sort out this issue. I searched all over the net but I didn't get any useful result. So any help is appreciable.

I am looking forward for your quick response.

Thanks,
San
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:23 PM.