1--TEST-- 2Pdo\Sqlite load extension 3--EXTENSIONS-- 4pdo_sqlite 5--SKIPIF-- 6<?php 7if (!method_exists(Pdo\Sqlite::class, "loadExtension")) { 8 die("skip loading sqlite extensions is not supported"); 9} 10 11if (PHP_OS != "Linux") { 12 die("skip, only for linux"); 13} 14 15require __DIR__ . "/config.inc"; 16$location = getSpatialiteExtensionLocation(); 17if ($location === null) { 18 die("skip, mod_spatialite.so is not installed via libsqlite3-mod-spatialite"); 19} 20?> 21--FILE-- 22<?php 23 24require __DIR__ . "/config.inc"; 25 26$db = Pdo::connect('sqlite::memory:'); 27if (!$db instanceof Pdo\Sqlite) { 28 echo "Wrong class type. Should be Pdo\Sqlite but is " . get_class($db) . "\n"; 29} 30 31$db->loadExtension(getSpatialiteExtensionLocation()); 32 33$result = $db->query('SELECT AsText(Buffer(GeomFromText("LINESTRING(0 0, 1 0)"), 0.2)) as geometry_data;'); 34 35$row = $result->fetch(PDO::FETCH_ASSOC); 36if ($row === false) { 37 echo "Failed to get data from geometry."; 38 exit(-1); 39} 40 41if (array_key_exists('geometry_data', $row) !== true) { 42 echo "Data is not under key 'geometry_data'. Available array keys are:"; 43 var_dump(array_keys($row)); 44 exit(-1); 45} 46 47echo $row['geometry_data'] . "\n"; 48 49$row = $result->fetch(PDO::FETCH_ASSOC); 50 51if ($row !== false) { 52 echo "We appear to have more data than expected."; 53 var_dump($row); 54 exit(-1); 55} 56 57echo "Fin."; 58?> 59--EXPECT-- 60POLYGON((1 0.2, 1.010467 0.199726, 1.020906 0.198904, 1.031287 0.197538, 1.041582 0.19563, 1.051764 0.193185, 1.061803 0.190211, 1.071674 0.186716, 1.081347 0.182709, 1.090798 0.178201, 1.1 0.173205, 1.108928 0.167734, 1.117557 0.161803, 1.125864 0.155429, 1.133826 0.148629, 1.141421 0.141421, 1.148629 0.133826, 1.155429 0.125864, 1.161803 0.117557, 1.167734 0.108928, 1.173205 0.1, 1.178201 0.090798, 1.182709 0.081347, 1.186716 0.071674, 1.190211 0.061803, 1.193185 0.051764, 1.19563 0.041582, 1.197538 0.031287, 1.198904 0.020906, 1.199726 0.010467, 1.2 0, 1.199726 -0.010467, 1.198904 -0.020906, 1.197538 -0.031287, 1.19563 -0.041582, 1.193185 -0.051764, 1.190211 -0.061803, 1.186716 -0.071674, 1.182709 -0.081347, 1.178201 -0.090798, 1.173205 -0.1, 1.167734 -0.108928, 1.161803 -0.117557, 1.155429 -0.125864, 1.148629 -0.133826, 1.141421 -0.141421, 1.133826 -0.148629, 1.125864 -0.155429, 1.117557 -0.161803, 1.108928 -0.167734, 1.1 -0.173205, 1.090798 -0.178201, 1.081347 -0.182709, 1.071674 -0.186716, 1.061803 -0.190211, 1.051764 -0.193185, 1.041582 -0.19563, 1.031287 -0.197538, 1.020906 -0.198904, 1.010467 -0.199726, 1 -0.2, 0 -0.2, -0.010467 -0.199726, -0.020906 -0.198904, -0.031287 -0.197538, -0.041582 -0.19563, -0.051764 -0.193185, -0.061803 -0.190211, -0.071674 -0.186716, -0.081347 -0.182709, -0.090798 -0.178201, -0.1 -0.173205, -0.108928 -0.167734, -0.117557 -0.161803, -0.125864 -0.155429, -0.133826 -0.148629, -0.141421 -0.141421, -0.148629 -0.133826, -0.155429 -0.125864, -0.161803 -0.117557, -0.167734 -0.108928, -0.173205 -0.1, -0.178201 -0.090798, -0.182709 -0.081347, -0.186716 -0.071674, -0.190211 -0.061803, -0.193185 -0.051764, -0.19563 -0.041582, -0.197538 -0.031287, -0.198904 -0.020906, -0.199726 -0.010467, -0.2 0, -0.199726 0.010467, -0.198904 0.020906, -0.197538 0.031287, -0.19563 0.041582, -0.193185 0.051764, -0.190211 0.061803, -0.186716 0.071674, -0.182709 0.081347, -0.178201 0.090798, -0.173205 0.1, -0.167734 0.108928, -0.161803 0.117557, -0.155429 0.125864, -0.148629 0.133826, -0.141421 0.141421, -0.133826 0.148629, -0.125864 0.155429, -0.117557 0.161803, -0.108928 0.167734, -0.1 0.173205, -0.090798 0.178201, -0.081347 0.182709, -0.071674 0.186716, -0.061803 0.190211, -0.051764 0.193185, -0.041582 0.19563, -0.031287 0.197538, -0.020906 0.198904, -0.010467 0.199726, 0 0.2, 1 0.2)) 61Fin. 62