PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Internationalization » Translation2 » Bug #1825

no table prefix delivered to class?

Details

Request #1825no table prefix delivered to class?
Submitted2004-07-08 16:51 UTC
Frommichael dot klink at no-limits dot net
Assignedquipo
StatusClosed
PackageTranslation2
PHP Version4.3.6
OSWin XP
Roadmaps(Not assigned)

Comments

[2004-07-08 16:51 UTC] michael dot klink at no-limits dot net

Description:
------------
There where no table prefix in the query but in the options array, so I receive a DB error

The table definitions are included in the options array but why there is no table prefix in the query.

Reproduce code:
---------------
Error object
db_error Object ( [error_message_prefix] => [mode] => 1 [level] => 256 [code] => -2 [message] => DB Error: syntax error [userinfo] => SELECT FROM WHERE .group='metadata' AND .id='metadata_author' [nativecode=1064 ** You have an error in your SQL syntax near 'FROM WHERE .group='metadata' AND .id='metadata_author'' at line 1] [backtrace] => [callback] => )

The options array is:
Array ( [langs_avail_table] => test_languages [lang_id_col] => id [lang_meta_col] => iso [lang_name_col] => language [lang_errmsg_col] => error [strings_tables] => Array ( [en] => test_i18n [de] => test_i18n [es] => test_i18n [fr] => test_i18n [it] => test_i18n ) [string_id_col] => id [string_page_id_col] => group [string_text_col] => %s )

The log message is:
18:42:05 MODUL myCrossAssembler - myTranslation(): ERROR - SELECT FROM WHERE .group='metadata' AND .id='metadata_author' [nativecode=1064 ** You have an error in your SQL syntax near 'FROM WHERE .group='metadata' AND .id='metadata_author'' at line 1] [info]

Expected result:
----------------
I see nothing, because the table definition was not delivered to language2

[2004-07-08 20:11 UTC] michael dot klink at no-limits dot net

Hi, the code is:
-------------------------------------------------------------
function myTranslation($myData, $myGroup, $mySQLTable) {
$myConfig = new myConfig;
$mySQLType = $myConfig -> mySQLType;
$mySQLConfig = array(
phptype => $myConfig -> mySQLType,
username => $myConfig -> mySQLUsername,
password => $myConfig -> mySQLPassword,
hostspec => $myConfig -> mySQLHost,
database => $myConfig -> mySQLDataBase,
prefix => $myConfig -> mySQLPrefix
);
$mySQLOptions = array(
langs_avail_table => $mySQL[Prefix]."_languages",
lang_id_col => "id",
lang_meta_col => "iso",
lang_name_col => "language",
lang_errmsg_col => "error",
strings_tables=> array(
en => $mySQL[Prefix]."_".$mySQLTable."",
de => $mySQL[Prefix]."_".$mySQLTable."",
es => $mySQL[Prefix]."_".$mySQLTable."",
fr => $mySQL[Prefix]."_".$mySQLTable."",
it => $mySQL[Prefix]."_".$mySQLTable.""
),
string_id_col=> "id",
string_page_id_col => "group",
string_text_col=> "%s"
);
$myTranslation = new Translation2($mySQLDriver, $mySQLConfig, $mySQLOptions);
if(PEAR::isError($myTranslation)) {
$myLogFile = new myLogFile("MODUL myCrossAssembler - myTranslation(): CAN'T CONNECT TO mySQL - ".$myTranslation -> getDebugInfo()."");
}
else {
$myLogFile = new myLogFile("MODUL myCrossAssembler - myTranslation(): CONNECTED TO mySQL");
}
$myTranslation -> setLang($this -> myLanguage());
$myTranslation -> setPageID($page);
$myTranslation =& $myTranslation -> getDecorator("Lang");
$myTranslation -> setOption("fallbackLang", "en");
$myTranslation =& $myTranslation -> getDecorator("Lang");
$myTranslation -> setOption("fallbackLang", "de");
if(is_array($myData)) {
$myTranslation -> setParams($myData);
$myTranslation = $myTranslation -> get($myData[0]);
if(PEAR::isError($myTranslation)) {
$myLogFile = new myLogFile("MODUL myCrossAssembler - myTranslation(): ERROR - ".$myTranslation -> getDebugInfo()."");
print_r($myTranslation -> getDebugInfo());
}
else {
$myLogFile = new myLogFile("MODUL myCrossAssembler - myTranslation(): GET TRANSLATION FOR ".$myData[0]."");
}
}
else {
$myTranslation = $myTranslation -> get($myData);
if(PEAR::isError($myTranslation)) {
$myLogFile = new myLogFile("MODUL myCrossAssembler - myTranslation(): ERROR - ".$myTranslation -> getDebugInfo()."");
print_r($myTranslation -> getDebugInfo());
}
else {
$myLogFile = new myLogFile("MODUL myCrossAssembler - myTranslation(): GET TRANSLATION ".$myTranslation." FOR ".$myData." IN GROUP ".$myGroup."");
}
}
return $myTranslation;
}

[2004-07-09 09:43 UTC] michael dot klink at no-limits dot net

Sorry, the Problem is solved. There was an error in my script in

en => $mySQL[Prefix]."_".$mySQLTable."",

it should be

en => $myConfig -> mySQLPrefix."_".$mySQLTable."",

But another question is why I cannot use a existing connection from pear DB? For every Translation it creates a new connection with

new Translation2($mySQLDriver, $mySQLConfig, $mySQLOptions);

using a existing connaction, as example

new Translation2($_SESSION[connection], $mySQLOptions);

or something else should be possible.

[2004-07-09 11:31 UTC] michael dot klink at no-limits dot net

No, this solution is not possible.

In bd_nestedset I con do this:

$mySQLOptions = array(
id => "id",
root => "rootid",
sequence => "norder",
level => "level",
lft => "l",
rgt => "r",
name => "name",
status => "status"
);
$myNestedSet = DB_NestedSet::factory($mySQLDriver = $myConfig -> mySQLDriver, $_SESSION[mySQLConnection], $mySQLOptions);

That use the connetion from the session object.