zero row returned using notorm

28 views
Skip to first unread message

Mohd Zulkarnain Jaranee

unread,
Aug 30, 2015, 4:43:10 AM8/30/15
to NotORM

Hi all, i have the following issue.

Issue: Query return zero row using notORM.

Steps taken to fix it but didnt work:

  1. Check connection db -> no error, connection established
  2. Check instance initialization -> obj inst. created succesfully
  3. Check syntax -> no error
  4. Check table name exist || !exist -> table name exist
  5. Check no. of row in table rates_call either rows > 0 || = 0 -> no. of rows > 0

Code:

require 'NotORM.php';
$conn = new PDO($dsn, $db_username, $db_password) or die ("can't connect");
$db = new NotORM($conn) or die ("instance not created");
$rates = array();
foreach($db->rates_call() as $rate)   
{ 
   $rates[] = array(
    "country_name" => $rate[country_name],
    "rate" => $rate[rates] 
   ); 
   echo "in foreach loop";
}
echo json_encode($rates);

Based on the code, the foreach loop not executed bcoz the no. of row returned is zero but in my database table, having few line of rows. I already tried using PDO aswell, it returned zero result also. Appreciate your assistant.

Mohd Zulkarnain Jaranee

unread,
Aug 30, 2015, 7:19:19 AM8/30/15
to NotORM

I did silly mistake at my PDO connection...

I wrote:

  $dsn = 'mysql:host:localhost;dbname=dtbasname';

It should be like this

  $dsn = 'mysql:host=localhost;dbname=dtbasname';

I accidentaly wrote ':' instead of '=' in between host and localhost.

Reply all
Reply to author
Forward
0 new messages