Jump to content

Recommended Posts

Posted

You need to establish a connection to the external/remote database you want to use, and then run the queries with the usual framework code to retrieve/display the data:

 

The first codebox shows an example of how to start an external database connection.

Posted

I have connect, but how i must use $table?

 
$connection = \IPS\Db::i( 'external', array(
    'sql_host'        => 'localhost',
    'sql_user'        => 'username',
    'sql_pass'        => 'password',
    'sql_database'    => 'database_name',
    'sql_port'        => 3306,
    'sql_socket'    => '/var/lib/mysql.sock',
    'sql_utf8mb4'    => true,
) );

$table = new IPS\Helpers\Table\Db( 'core_test', 'app=core&module=test&section=test1', NULL, NULL, $connection);

 

Posted

What’s the question? What are you trying to achieve/what’s the issue you’ve run into? 
 

what’s happening when you try to show the table?

without any further code i would guess:

- your passed url is wrong

- You‘re missing the table templates 

Posted (edited)
Error: Class name must be a valid object or a string (0)
#0/public_html/system/Theme/Dev/Template.php(171): IPS\Theme\theme_core_front_tables_rows(Object(IPS\Helpers\Table\Db), Array, Array)
#1 /public_html/system/Theme/Theme.php(4625) : eval()'d code(513): IPS\Theme\Dev\_Template->__call('rows', Array)
#2 /public_html/system/Theme/Dev/Template.php(171): IPS\Theme\theme_core_front_tables_table(Object(IPS\Helpers\Table\Db), Array, Array, NULL, false)
#3 /public_html/system/Helpers/Table/Table.php(579): IPS\Theme\Dev\_Template->__call('table', Array)
#4 /public_html/system/Theme/Theme.php(4625) : eval()'d code(422): IPS\Helpers\Table\_Table->__toString()
#5 /public_html/system/Theme/Dev/Template.php(171): IPS\Theme\theme_core_front_global_globalTemplate(' - Invision Com...', Object(IPS\Helpers\Table\Db), Array)
#6 /public_html/system/Dispatcher/Dispatcher.php(173): IPS\Theme\Dev\_Template->__call('globalTemplate', Array)
#7 /public_html/system/Dispatcher/Standard.php(113): IPS\_Dispatcher->finish()
#8 /public_html/system/Dispatcher/Front.php(558): IPS\Dispatcher\_Standard->finish()
#9 /public_html/system/Dispatcher/Dispatcher.php(155): IPS\Dispatcher\_Front->finish()
#10 /public_html/index.php(13): IPS\_Dispatcher->run()
#11 {main}

I probably have an incorrectly connected external database in $table

 

	$connection = \IPS\Db::i( 'external', array(
    'sql_host'        => 'localhost',
    'sql_user'        => 'username',
    'sql_pass'        => 'password',
    'sql_database'    => 'database_name',
    'sql_port'        => 3306,
    'sql_socket'    => '/var/lib/mysql.sock',
    'sql_utf8mb4'    => true,
) );

$database = \IPS\Db::i('external');
		$tablee = 'table_db';
		$baseUrl = \IPS\Http\Url::internal( 'app=test&module=test&controller=test' );
		$table = new \IPS\Helpers\Table\Db($tablee, $baseUrl, NULL, NULL, $database);
$table->include = array( 'id', 'id_name' );
		\IPS\Output::i()->output = $table;

 

Edited by deple
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...