From: Jonny B. <jo...@ti...> - 2010-02-21 15:36:52
|
Sorry, i haven't had time to check the multi-tiki stuff on this, and am unlikely to find any soon... (got to get the basics working) remind me in a week or three? jb On 21 Feb 2010, at 11:59, Stephane Casset wrote: > Le Sat, Feb 20, 2010 at 07:28:46PM -0500, lindon écrivait : >> >> Thanks Jonny! >> I notice now that I'm displaying double results with PDO, so still needs some fixing, but at least there are results and no fatal error. > > If you use direct connection to the db without going through _query() > you need to pass PDO::FETCH_ASSOC to PDO to avoid the double results > both as associative array and as indexed values... > >> Stephane - will take your suggestion too - thanks. Hopefully plugin dbreport next - should be similar fix. > > You should go thtough the absract layer it would be easier I think, I > did look closely a the plugin but should be doable... > >> Regards, >> lindon >> >> On Sat, Feb 20, 2010 at 4:21 PM, Stephane Casset <[1]se...@lo...> wrote: >> >> Le Sat, Feb 20, 2010 at 10:16:16PM +0100, Stephane Casset écrivait : >> >>> Le Sat, Feb 20, 2010 at 08:54:27PM +0000, [2]li...@us... écrivait : >>>> Revision: 25445 >>>> [3]http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=25445&view=rev >>>> Author: lindonb >>>> Date: 2010-02-20 20:54:26 +0000 (Sat, 20 Feb 2010) >>>> >>>> Log Message: >>>> ----------- >>>> [FIX] Now Plugin SQL works with both pdo and adodb (broke in 4.0 with >>>> move to pdo). Assumes pdo unless db.local.php has $api_tiki set to >>>> adodb. >>> >>> Seems this won't work with multiTiki, but someone more fluent than me on >>> Multi should look at it, Jonny maybe ? ;p >>> >>>> Modified Paths: >>>> -------------- >>>> trunk/lib/tikilib.php >>>> trunk/lib/wiki-plugins/wikiplugin_sql.php >>>> >>>> Modified: trunk/lib/tikilib.php >>>> =================================================================== >>>> --- trunk/lib/tikilib.php 2010-02-20 20:43:42 UTC (rev 25444) >>>> +++ trunk/lib/tikilib.php 2010-02-20 20:54:26 UTC (rev 25445) >>>> @@ -119,6 +119,7 @@ >>>> } >>>> >>>> function get_db_by_name( $name ) { >>>> + include_once ('tiki-setup.php'); >>>> if( $name == 'local' || empty($name) ) { >>>> return TikiDb::get(); >>>> } else { >>>> @@ -139,17 +140,20 @@ >>>> $dbhost = strtok( $parsedsn, "/" ); >>>> $parsedsn = substr( $parsedsn, strlen($dbhost) + 1 ); >>>> $database = $parsedsn; >>>> - >>>> - require_once ('lib/adodb/adodb.inc.php'); >>>> - $dbsqlplugin = ADONewConnection($dbdriver); >>>> - >>>> - if( $dbsqlplugin->NConnect( $dbhost, $dbuserid, $dbpassword, $database ) ) { >>>> - require_once 'lib/core/lib/TikiDb/Adodb.php'; >>>> - >>>> - $connectionMap[$name] = new TikiDb_AdoDb( $dbsqlplugin ); >>>> + >>>> + $api_tiki = null; >>>> + require 'db/local.php'; >>>> + if (isset($api_tiki) && $api_tiki == 'adodb') { >>>> + require_once ('lib/adodb/adodb.inc.php'); >>>> + $dbsqlplugin = ADONewConnection($dbdriver); >>>> + if( $dbsqlplugin->NConnect( $dbhost, $dbuserid, $dbpassword, $database ) ) { >>>> + require_once ('lib/core/lib/TikiDb/Adodb.php'); >>>> + $connectionMap[$name] = new TikiDb_AdoDb( $dbsqlplugin ); >>>> + } >>>> + } else { >>>> + $connectionMap[$name] = new PDO("$dbdriver:host=$dbhost;dbname=$database", $dbuserid, $dbpassword); >>>> } >>>> } >>>> - >>>> return $connectionMap[$name]; >>>> } >>>> } >>>> >>>> Modified: trunk/lib/wiki-plugins/wikiplugin_sql.php >>>> =================================================================== >>>> --- trunk/lib/wiki-plugins/wikiplugin_sql.php 2010-02-20 20:43:42 UTC (rev 25444) >>>> +++ trunk/lib/wiki-plugins/wikiplugin_sql.php 2010-02-20 20:54:26 UTC (rev 25445) >>>> @@ -28,8 +28,9 @@ >>>> } >>>> >>>> function wikiplugin_sql($data, $params) { >>>> + >>>> global $tikilib; >>>> - >>>> + require 'db/local.php'; >> >> Unneeded see below... >> >>>> extract ($params,EXTR_SKIP); >>>> >>>> if (!isset($db)) { >>>> @@ -70,11 +71,16 @@ >>>> } else { >>>> return '~np~' . tra('Could not obtain valid DSN connection.') . '~/np~'; >>>> } >>>> - >>>> + >>>> $first = true; >>>> $class = 'even'; >>>> + if (isset($api_tiki) && $api_tiki == 'adodb') { >>>> + $fetch = 'fetchRow'; >>>> + } else { >>>> + $fetch = 'fetch'; >>>> + } >>>> + while ($result && $res = $result->$fetch()) { >> >> You can use fetchAll and loop on the result instead... should be good >> for both PDO and adoDB... >> >>>> >>>> - while ($result && $res = $result->fetchRow()) { >>>> if ($first) { >>>> $ret .= "<div align='center'><table class='sortable'><tr>"; >>>> >>>> >> >> A+ >> >> -- >> Stéphane Casset LOGIDÉE sàrl Se faire plaisir d'apprendre >> 1a, rue Pasteur Tel : +33 388 23 69 77 [4]ca...@lo... >> F-67540 OSTWALD Fax : +33 388 23 69 77 [5]http://logidee.com >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> [6]http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Tikiwiki-cvs mailing list >> [7]Tik...@li... >> [8]https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs >> >> References >> >> 1. mailto:se...@lo... >> 2. mailto:li...@us... >> 3. http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=25445&view=rev >> 4. mailto:ca...@lo... >> 5. http://logidee.com/ >> 6. http://p.sf.net/sfu/intel-sw-dev >> 7. mailto:Tik...@li... >> 8. https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs > >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Tikiwiki-cvs mailing list >> Tik...@li... >> https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs > > > -- > Cordialement > -- > Stéphane Casset LOGIDÉE sàrl Se faire plaisir d'apprendre > 1a, rue Pasteur Tel : +33 388 23 69 77 ca...@lo... > F-67540 OSTWALD Fax : +33 388 23 69 77 http://logidee.com > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Tikiwiki-cvs mailing list > Tik...@li... > https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs |