Hi Marc,
You can't easily search the DB because the capabilities are serialized and not expanded through their fallback devices. This question has come up before, so I thought I would post a solution - it's very slow and only works with MySQL, but it will let you search for which devices have which capability.
- Code: Select all
<?php
require_once dirname(__FILE__).'/../TeraWurfl.php';
$search = array(
'product_info.is_tablet' => true,
);
$tw = new TeraWurfl();
$db = new mysqli(TeraWurflConfig::$DB_HOST, TeraWurflConfig::$DB_USER, TeraWurflConfig::$DB_PASS, TeraWurflConfig::$DB_SCHEMA);
$res = $db->query("SELECT * FROM `TeraWurflMerge` WHERE `actual_device_root` = 1");
while($row = $res->fetch_assoc()){
$caps = unserialize($row['capabilities']);
$id = $caps['id'];
$caps = null;
$tw->getFullCapabilities($id);
$brand = $tw->capabilities['product_info']['brand_name'];
$model = $tw->capabilities['product_info']['model_name'];
$market = $tw->capabilities['product_info']['marketing_name'];
foreach($search as $key => $val){
list($group, $name) = explode('.', $key);
if(!(array_key_exists($group,$tw->capabilities) && array_key_exists($name,$tw->capabilities[$group]))){
throw new Exception("Error: group $group or capability $name do not exist in the Tera-WURFL database.\n");
}
if($tw->capabilities[$group][$name] == $val){
// This is a matching device
echo "$id, $brand $model $market\n";
last;
}
}
}
Here's the output from the script:
- Code: Select all
# php search.php
nokia_n810_ver1, Nokia N810
apple_ipad_ver1, Apple iPad
mot_sholest_ver1, Motorola Sholes Tablet
dell_streak_ver1, Dell Streak
samsung_galaxy_tab_ver1, Samsung Galaxy Tab
zte_v9_ver1, ZTE V9
softbank_001dl_ver1, Softbank 001DL
archos_a101it_ver1, Archos A101IT
coby_mid7015_ver1, Coby MID7015 Kyros
viewsonic_viewpad7_ver1, ViewSonic ViewPad7
nextbook_next2_ver1, Nextbook Next2
huawei_ideos_s7_ver1, Huawei IDEOS S7
zenithink_zt180_ver1, Zenithink zt180
motorola_xoom_ver1, Motorola Xoom
lg_v900_ver1, LG V900 Optimus Pad
dell_streak_7_ver1, Dell Streak 7 Streak 7
nextbook_next3_ver1, Nextbook NXM901 Next3
acer_iconia_tab_a500_ver1, Acer Iconia Tab A500 Picasso
acer_iconia_tab_a100_ver1, Acer Iconia Tab A100 Vangogh
toshiba_folio100_ver1, Toshiba Folio 100
rim_playbook_ver1, RIM PlayBook
You can specify whatever capabilities you want to look for in the
search array by concatenating the group name and capability name (e.g. $tw->capabilities['display']['resolution_width'] would be "display.resolution_width") and specifying the value you want to search for (e.g. 320):
- Code: Select all
$search = array(
'display.resolution_width' => 320,
'display.resolution_height' => 320,
);