AdoDB

Permalink
Okay, so AdoDB is not used anymore (Whyyyyy? Why in gods name????).

While GetAll and a few other AdoDB calls seem still to work others don't.
What's the simple equivalent now to "CacheGetAll"?

 
mkly replied on at Permalink Best Answer Reply
mkly
ADODB has been replaced with Doctrine 2[0]. A compatibility layer[1] has been added that provides some backwards compatibility with the most commonly used ADODB methods. Doctrine does provide a caching layer you can use and DBAL[2] is pretty similar to ADODB / PDO.

As per caching, here is a quick code snippet to get you started
<?php
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Concrete\Core\Cache\Adapter\DoctrineCacheDriver;
$db = \Database::get();
// replace 'my_sweet_page_list' with your unique cache key
// replace 3600 with your desired lifetime of the cache in seconds
$cache = new DoctrineCacheDriver('cache/expensive');
$profile = new QueryCacheProfile(3600, 'my_sweet_page_list', $cache);
$stmt = $db->executeQuery(
    'SELECT * FROM Pages WHERE cID > ?',
    array(100),
    array(),
    $profile
);
foreach ($stmt->fetchAll() as $res) {


[0]http://www.doctrine-project.org/...
[1]https://github.com/concrete5/concrete5-5.7.0/blob/develop/web/concre...
[2]http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/r...

Edit: Refactor for clarity
Kiesel replied on at Permalink Reply
Thanks a lot for your help! I'll try that out.

I still don't understand why AdoDB, which is my absolute favorite has been replaced. It was very easy to use. One of the reasons that drew me to concrete5 was the use of AdoDB, so I'm very disappointed that it has been replaced.

Performance reason is the only thing that comes in mind. Oh well... :(
Wonder if the slight performance boost is worth to replace easy one-liners with a crap-load of code. In my eyes it's not. If I want speed I use phalcon anyway.
Kiesel replied on at Permalink Reply
Mhm, okay not that much code after I gave it a good look. Must have been Mr. Grumpy that spoke :)
Kiesel replied on at Permalink Reply
Alright, so I tried a few things, and it seems like things really got more complicated and tedious. Another problem that I have now is that a simple query worked in AdoDB (5.6) flawless:

$sql = "SELECT lotsofblablastuffandjoins WHERE mmctm.mcID = ? GROUP BY msm.mID ORDER BY msm.movieYear ASC LIMIT ?,?"; 
$vals = array(12,0,999);
$rows = $db->GetAll($sql, $vals);


I don't write the whole Select part as it's a lot and doesn't matter to the problem. Fact is, it worked without a problem but doesn't works anymore in 5.7 and the Doctrine->AdoDB abstraction layer. Also doesn't work in Doctrin's own code. If I remove the last two "?" and replace them directly with the numbers 0 and 999 it works. So the problem is solely with the last two ?'s.

Any idea? I worked hours on it already and it costs a lot of nerves.
Juha replied on at Permalink Reply
Juha
The problem probably is that Doctrine (or PDO) interprets the offset and limit as strings and quotes them. Try writing the query like this:

$sql = "SELECT lotsofblablastuffandjoins WHERE mmctm.mcID = ? GROUP BY msm.mID ORDER BY msm.movieYear ASC LIMIT ?,?"; 
$vals = array(12,0,999);
$stmt = $db->executeQuery( $sql, $vals, array( \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT ) );
$rows = $stmt->fetchAll();
Kiesel replied on at Permalink Reply
Thank you, that was it!

Used your solution and now it works. I have to change a crap-load of code now, but at least I'm not stuck anymore.