Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7517397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:26:16+00:00 2026-05-30T01:26:16+00:00

When I SELECT a Geometry column with AsText() , the returned value is truncated

  • 0

When I SELECT a Geometry column with AsText(), the returned value is truncated to 8193 bytes.

This looks like a bug to me, but I’d like to post here first to see if I’m missing anything with the way prepared statements work under MySQLi. Are there any settings I’m overlooking here?

Chances are I either I’m Doing It Wrong, or there is a setting I don’t know about.

All test cases below except the first truncate the geom field to 8193 bytes. I’m pulling my hair out trying to determine the cause of this.

PHP Version: PHP 5.3.3-7 with Suhosin-Patch (cli) (built: Jan 5 2011 12:52:48)
MySQL Version: mysql Ver 14.12 Distrib 5.0.32, for pc-linux-gnu (i486) using readline 5.2

<?php
$con = new mysqli(HOST, USER, PASS, DB);
$con->query("DROP TABLE IF EXISTS `mytable`");
$con->query("CREATE TABLE `mytable` (`text` TEXT , `geom` GEOMETRY)");

for ($i = 0; $i < 1300; ++$i) {
    $points[] = "$i $i";
}

$wkt = "LINESTRING(" . implode(',', $points) . ")";

$con->query("INSERT INTO `mytable` (`text`,`geom`) VALUES ('$wkt', GeomFromText('$wkt'))");

/* CASE #1 */
    echo "With store_result(), no string function on `text`:\n";
    $stmt = $con->prepare('SELECT `text`, ASTEXT(`geom`) FROM `mytable`');
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($text, $geom);
    $stmt->fetch();
    $stmt->close();
    echo "  Text is ".strlen($text)." bytes, Geom is ".strlen($geom)." bytes\n";
    unset($text);
    unset($geom);

/* CASE #2 */
    echo "With store_result(), left(`text`,10791):\n";
    $stmt = $con->prepare('SELECT LEFT(`text`,10791), ASTEXT(`geom`) FROM `mytable`');
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($text, $geom);
    $stmt->fetch();
    $stmt->close();
    echo "  Text is ".strlen($text)." bytes, Geom is ".strlen($geom)." bytes\n";
    unset($text);
    unset($geom);

/* CASE #3 */
    echo "With store_result(), only the `geom` column:\n";
    $stmt = $con->prepare('SELECT ASTEXT(`geom`) FROM `mytable`');
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($geom);
    $stmt->fetch();
    $stmt->close();
    echo "  Text is ".@strlen($text)." bytes, Geom is ".strlen($geom)." bytes\n";
    unset($text);
    unset($geom);

/* CASE #4 */
    echo "Without store_result(), no string function on `text`:\n";
    $stmt = $con->prepare( 'SELECT `text`, ASTEXT(`geom`) FROM `mytable`');
    $stmt->execute();

    $stmt->bind_result($text, $geom);
    $stmt->fetch();
    $stmt->close();
    echo "  Text is ".strlen($text)." bytes, Geom is ".strlen($geom)." bytes\n";
?>

Expected Result:

With store_result(), no string function on `text`:
  Text is 10791 bytes, Geom is 10791 bytes
With store_result(), left(`text`,10791):  
  Text is 10791 bytes, Geom is 10791 bytes
With store_result(), only the `geom` column:
  Text is 0 bytes, Geom is 10791 bytes
Without store_result(), no string function on `text`:
  Text is 10791 bytes, Geom is 10791 bytes

Here is my actual result when running the above:

With store_result(), no string function on `text`:
  Text is 10791 bytes, Geom is 10791 bytes
With store_result(), left(`text`,10791):  
  Text is 10791 bytes, Geom is 8193 bytes
With store_result(), only the `geom` column:
  Text is 0 bytes, Geom is 8193 bytes
Without store_result(), no string function on `text`:
  Text is 10791 bytes, Geom is 8193 bytes
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:26:18+00:00Added an answer on May 30, 2026 at 1:26 am

    This issue went away when PHP was upgraded to 5.3.8.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've a SDO_GEOMETRY column containing quite large multi polygons , defined like this: INSERT
SELECT pe.prodtree_element_id prodID, pe.prodtree_element_name_s, li.line_name, av2.value FROM prodtree_element pe LEFT JOIN prodtree_link pl ON
I have a scene with basic geometry (pick demo) I want when I select
SELECT `NAME` FROM world_boundaries WHERE Within(GeomFromText('POINT(8.5929098 50.0286713)'), ogc_geom); Why does this query return 3
SELECT * FROM [makes$] WHERE Corporate Name='Champion Enterprises, Inc.' I'm running this query on
I have been trying the following but always fails, roomTypeSQL = SELECT spftype FROM
SELECT p.value AS __color__, milestone AS __group__, milestone, priority, time AS created, COUNT(t.id) as
select * from table where key='çmyk' when i run this query on table that
If a table have a column A which is geometry type,and column B which
For the past 4 months or so we've been happily using this query: SELECT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.