Categories > TinyButStrong general >

TbsSQL 3.2 fails -- no error message

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Alan Lake
Date: 2012-08-03
Time: 19:26

TbsSQL 3.2 fails -- no error message

I'm using PHP 5.4.4 and MySQLi 5.5.25a.  Executing attempt 1 below, "@new MySQLi($db_params...,", I am successful.  Executing attempt 2 "    $db = new clsTbsSQL();", I am not successful.  The code from the class appears to hang up on line 882 of tbssql_mysqli.php, the "@new MySQLi..." statement of "_Dbs_Connect()".
My copy of config.php contains the value of $db_params as a global value.  My copy of tbssql_mysqli.php has not been changed except to add a few (?) echos and var_dumps to confirm that I have the values that I think I do at different points.  I do.
<?
    include("/home/alan/domains/lakeinfoworks.com/httpdocs/ckt/config/config.php");
    include("/home/alan/domains/lakeinfoworks.com/httpdocs/ckt/tbssql_mysqli.php");
$Id = @new MySQLi($db_params['srv'],
  $db_params['uid'],$db_params['pwd'],$db_params['db']);
echo "attempt 1: ";var_dump($Id);echo "<br />";
            
echo "\$db_params: "; var_dump($db_params);echo "<br />";
if(class_exists('clsTbsSql')) {
    echo "attempt 2: clsTbsSql exists<br />";
  }else{
    echo "attempt 2: clsTbsSql doesn't exist<br />";
    $db = new clsTbsSQL();
echo "\$db: "; var_dump($db);echo "<br />";
    $db->Connect('db_params');
  }
?>
Help is appreciated.
By: Skrol29
Date: 2012-08-05
Time: 23:53

Re: TbsSQL 3.2 fails -- no error message

Hi,

Don't you have any error message ?
By: Alan Lake
Date: 2012-08-06
Time: 09:10

Re: TbsSQL 3.2 fails -- no error message

Hi.
No error message.  The last output was the echo  beginning "attempt 2...".  I suspect that the code hung or went into a loop rather than failed.

I erred in noting line 882 was where the code hung up.  My diagnostic echos distorted the actual location.  The rest of the statement still stands.
By: Skrol29
Date: 2012-08-06
Time: 14:10

Re: TbsSQL 3.2 fails -- no error message

If your snippet is copy/past of your original code then I can say it cannot work.
If class_exists('clsTbsSql') is true, then the snippet does not try to connect.
By: Alan Lake
Date: 2012-08-06
Time: 15:45

Re: TbsSQL 3.2 fails -- no error message

This snippet is not a part of my original code.
if(class_exists('clsTbsSql')) {
    echo "attempt 2: clsTbsSql exists<br />";
  }else{
    echo "attempt 2: clsTbsSql doesn't exist<br />";
    $db = new clsTbsSQL();
echo "\$db: "; var_dump($db);echo "<br />";
    $db->Connect('db_params');
  }
If the class did exist, I'd get the message that it existed, but I don't.  I get the message that "clsTbsSql" doesn't exist".  The code hangs on the statement "$db = new cslTbsSQL()".  More accurately, it hangs on the statement in tbssql_mysqli.php, function _Dbs_Connect() , at the "@new MySQLi..." statement.
By: Skrol29
Date: 2012-08-07
Time: 23:21

Re: TbsSQL 3.2 fails -- no error message

>If the class did exist, I'd get the message that it existed, but I don't.

Maybe because of the case clsTbsSql vs clsTbsSQL.


I cannot try your configuration with PHP 5.4.4 for now.

But I suggest that you track the problem by changing :
$this->Id = @new MySQLi($srv,$uid,$pwd,$db);
with :
$this->Id = new MySQLi($srv,$uid,$pwd,$db);
in the source code of TbsSQL.

This should display the full error message of MySQLi.
You can also take the opportunity to check variables  $srv, $uid, $pwd and $db, and see of the values are what you're expecting.
By: Alan Lake
Date: 2012-08-08
Time: 01:39

Re: TbsSQL 3.2 fails -- no error message

Writing clsTbsSQL instead of clsTbsSql was a big oversight on my part, but unfortunately fixing it didn't solve the problem.

I changed the source code of the @new MySQLi statement, removing the "@" sign, but I got no error message.  This is why I suspect that there is a loop or something to make the code hang within "new MySQLi".  If this is true, then the problem is not mine or TBS', but something with php-mysql.  I am just wondering if you'd heard of it.

I have an echo statement to check the connection variables.  They are what I expect.

In my snippit, "attempt 1", where MySQLi is executed outside of a class, the connection is successful.  It fails when I attempt to connect from within a class, such as clsTbsSql.
By: Alan Lake
Date: 2012-08-26
Time: 12:57

Re: TbsSQL 3.2 fails -- no error message

I added a class that doesn't use clsTbsSql to my test which connects to mysqli.  It works.  But when I try to connect with clsTbsSql, it still doesn't work. (My software,is PHP 5.4.4 and MySQLi 5.5.25a)  Here is my latest test program followed by the results.  Notice that the Id in the first two tests is populated and that there are no errors.
<?php
    include("/home/alan/domains/lakeinfoworks.com/httpdocs/ckt/config/config.php");
    include("/home/alan/domains/lakeinfoworks.com/httpdocs/ckt/tbssql_mysqli.php");
    include("/home/alan/domains/lakeinfoworks.com/httpdocs/ckt/app/models/tbssql_mysqli.php");

class TestMysqli {
  function __construct($srv,$uid,$pwd,$db) {
    $this->Id = @new MySQLi($srv,$uid,$pwd,$db);
  }
  function getId() {
    return $this->Id;
  }
}

$Id = @new MySQLi($db_params['srv'],
  $db_params['uid'],$db_params['pwd'],$db_params['db']);
echo "Executed outside of any class<br />";var_dump($Id);echo "<br /><br />";

echo "Executed within TestMysqli class that I wrote<br />";
  $obj = new TestMysqli($db_params['srv'],
      $db_params['uid'],$db_params['pwd'],$db_params['db']);
  $id = $obj->getId();
echo "\$obj = ";print_r($obj);echo "<br /><br />";
            
echo "Executing clsTbsSql<br />";            
//echo "\$db_params: "; var_dump($db_params);echo "<br />";
  $db = new clsTbsSql();
echo "\$db: "; var_dump($db);echo "<br />";
  $db->Connect('db_params');
echo "\$db->Connect() done<br />";   
?>

Results:
Executed outside of any class
object(mysqli)#1 (19) { ["affected_rows"]=> int(0) ["client_info"]=> string(75) "mysqlnd 5.0.10 - 20111026 - $Id: b0b3b15c693b7f6aeb3aa66b646fee339f175e39 $" ["client_version"]=> int(50010) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["field_count"]=> int(0) ["host_info"]=> string(15) "erie via TCP/IP" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(6) "5.5.27" ["server_version"]=> int(50527) ["stat"]=> string(132) "Uptime: 5122 Threads: 1 Questions: 30 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.005" ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(17) ["warning_count"]=> int(0) }

Executed within TestMysqli class that I wrote
$obj = TestMysqli Object ( [Id] => mysqli Object ( [affected_rows] => 0 [client_info] => mysqlnd 5.0.10 - 20111026 - $Id: b0b3b15c693b7f6aeb3aa66b646fee339f175e39 $ [client_version] => 50010 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [error_list] => Array ( ) [field_count] => 0 [host_info] => erie via TCP/IP [info] => [insert_id] => 0 [server_info] => 5.5.27 [server_version] => 50527 [stat] => Uptime: 5122 Threads: 2 Questions: 30 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.005 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 18 [warning_count] => 0 ) )

Executing clsTbsSql
clsTbsSql::_Dbs_Prepare()"
$db: object(clsTbsSql)#4 (15) { ["Version"]=> string(47) "3.2 for MySQL with Improved Extrension (mysqli)" ["Id"]=> bool(false) ["SqlNull"]=> string(4) "NULL" ["DefaultRowType"]=> string(5) "array" ["CacheDir"]=> string(1) "." ["CacheTimeout"]=> bool(false) ["TempCacheTimeout"]=> bool(false) ["CacheAutoClear"]=> int(10080) ["CacheSuffix"]=> string(0) "" ["InitMsg"]=> bool(true) ["InitCsl"]=> bool(true) ["_CacheCurrSql"]=> bool(false) ["Mode"]=> int(1) ["TbsKey"]=> string(6) "tbssql" ["_Tbs_FetchFct"]=> &string(20) "_Tbs_RsFetch_Default" }
clsTbsSql::Connect
clsTbsSql::Connect:before $this_Dbs_Connect
clsTbsSql::_Dbs_Connect:$this->Mode = "1"
clsTbsSql::_Dbs_Connect:before calling new MySQLi
function_exists('mysqli_connect') = bool(true)
---
It looks as though clsTbsSql hangs.
By: Skrol29
Date: 2012-08-28
Time: 01:50

Re: TbsSQL 3.2 fails -- no error message

Hi Alan,

I've tested your test code and it worked for me on PHP 5.4.3 + MySQLi 5.5.24-log.

Executing clsTbsSql
$db:

object(clsTbsSql)[4]
  public 'Version' => string '3.2 for MySQL with Improved Extrension (mysqli)' (length=47)
  public 'Id' => boolean false
  public 'SqlNull' => string 'NULL' (length=4)
  public 'DefaultRowType' => string 'array' (length=5)
  public 'CacheDir' => string '.' (length=1)
  public 'CacheTimeout' => boolean false
  public 'TempCacheTimeout' => boolean false
  public 'CacheAutoClear' => int 10080
  public 'CacheSuffix' => string '' (length=0)
  public 'InitMsg' => boolean true
  public 'InitCsl' => boolean true
  public '_CacheCurrSql' => boolean false
  public 'Mode' => int 1
  public 'TbsKey' => string 'tbssql' (length=6)
  public '_Tbs_FetchFct' => &string '_Tbs_RsFetch_Default' (length=20)


$db->Connect() done

I need more time to test on PHP 5.4.4.
By: Alan Lake
Date: 2012-08-28
Time: 14:00

Re: TbsSQL 3.2 fails -- no error message

Here's a workaround from the __construct function of my own Database class:
  function __construct() {
    $db_params = $GLOBALS['db_params'];
    $this->Id = @new MySQLi($db_params['srv'],
      $db_params['uid'],$db_params['pwd'],$db_params['db']);
    $this->db = new clsTbsMySqli;
    $this->db->Id = $this->Id;
    $sql = "USE ".$db_params['db'];
    $this->db->Execute($sql);
    $this->db->Execute("SET NAMES 'utf8'");
    $sql = "CREATE TABLE IF NOT EXISTS templates (
      user int(11) AUTO_INCREMENT PRIMARY KEY,
      user_email varchar(30)

      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
    $this->db->Execute($sql);
  }
You had mentioned doing something like this in the TbsSql manual, but I had overlooked it.
Thanks for working on this, Skrol.