Is it possible in PDO to limit the character return? I'm trying the following but it simply doesn't return a results set no matter which field I put in the LEFT, yet the rest of the query in this case the id and title is returned as expected. Am I missing something?
$sql = "SELECT LEFT(content,10), id, title FROM posts";
$query = $this->db->prepare($sql);
$query->execute();
So I'm loading my model (above) via the controller like so:
$posts_model = $this->loadModel('PostsModel');
$posts = $posts_model->getAllPosts();
Then in my view Im echoing out the results like so:
<?php foreach ($posts as $post) { ?>
<tr>
<td><h3><?php if (isset($post->title)) echo $post->title; ?></h3></td>
<td><?php if (isset($post->content)) echo $post->content; ?></td>
</tr>
Not sure if this helps any? Like I say I can switch title and content around and it will echo them out it just wont echo the column in the LEFT part of the SQL statement. I've tried the raw mysql query in PHPMYAdmin and it returns the data as I expect just wont work in the live application using PDO.