Jump to content

Table with external database.


Go to solution Solved by DawPi,

Recommended Posts

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);

ย 

Link to comment
Share on other sites

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ย 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
ร—
ร—
  • Create New...