Home » Topics » Pods 1.x » SQL error
SQL error
This topic contains 6 replies, has 3 voices, and was last updated by logikal16 3 years, 8 months ago.
-
AuthorPosts
-
March 12, 2009 at 12:02 pm #158094
@freezewood – Did you initialize the Pod class with the name of one of your pods? E.g.
<pre><?php
// Bad
$Record = new Pod();// Good
$Record = new Pod(‘event’);
?></pre>March 14, 2009 at 10:07 am #158095@freezewood – Could you send a copy of the source code to us or give us a link to where this is happening?
April 20, 2009 at 9:37 am #158096@cybertrack – Do you remember if you got an error when you first tried adding the "_REPEATED" column?
September 7, 2009 at 7:13 pm #158097<pre><?php
$author_pod = new Pod(‘author’);
$author_pod->findRecords($orderby, $limit, $where);
while ($author_pod->fetchRecord())
{
echo $author_pod->get_field(‘name’);
}
?></pre>September 9, 2009 at 10:25 am #158098That fixed that problem but I think I am going about this incorrectly. Following is my entire pod page. The problem I am having now is that there can be more than one author for each essay and if there is, I want them separated by commas but I can’t seem to get that to work. I can do this all in a helper using implode (I already got that to work) but I am really trying to understand this better by bypassing templates and helpers and putting all the code directly in the pod page. This is where I run into problems.
As you can see, there are several pods being called on this page as I need detailed information from all of them.
<pre>
<?php
$essay_pod;
echo $essay_pod->showTemplate(‘essay_detail’);
echo ‘<hr />’;12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849//get the author array from the essay pod so it is specific to this essay's author.$authorArray = $essay_pod->get_field('essay_author');//pull out the id of the author, then inlclude variable in findRecords (orderby, limit, where) in where below//loop through the author array and showing the records for each author in the author_detail templateforeach ($authorArray as $author) {$authors = $author['id'];$record1 = new Pod('author');$record1->findRecords('t.last_name ASC', 9000, "t.id = '$authors'");echo $record1->showTemplate('author_detail');}//ESSAY LIST FROM BOOK//get the title array from the essay pod so it is specific to this essay's title.echo '<hr />';$essayArray = $pods->get_field('essay_title');echo '<h3>Other Essays <span class="prep">from </span><span class="title">';echo $pods->get_field('name');echo '</span></h3>';echo '<ul class="essay_links">';foreach ($essayArray as $essay) {$essays = $essay['id'];$essaylinks = new Pod('essay');$essaylinks->findRecords('t.name ASC', 9000, "t.id = '$essays'");//Bypass the template and pull links directly below//if statement to remove the current essay from the listif (($essay['id']) != $id_or_slug) {echo '<li><a href="/testing/smartpop/essay/';echo $essay['id'];echo '/">';echo $essay['name'];echo '</a> <span class="prep">by </span> ';while ($essaylinks->fetchRecord()) {$authorArray = $essaylinks->get_field('essay_author');//echo '<pre>'; print_r($authorArray); echo '</pre>';foreach ($authorArray as $author) {$names = $author['name'];echo $names;}}echo '</li>';}}echo '</ul>';?></pre>
September 9, 2009 at 4:08 pm #158093I am using a custom pod page and bypassing the template. Everything is working well for the most part but then I got stuck.
Instead of using
<pre>$pick_array = $this->get_field(‘name’); </pre>
as I would in a regular pod pageI am using
<pre>
$author_pod = new Pod(‘author’);
$author_pod->findRecords($orderby, $limit, $where);
$pick_array = $author_pod->get_field(‘name’);
</pre>
but I keep getting this error:
<pre>
Error: SQL failed; SQL: SELECT id FROM wp_pod WHERE datatype = ’14′ AND tbl_row_id IN (); Response: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘)’ at line 1
</pre>I am not sure why I am getting this error. Any ideas?
September 9, 2009 at 4:08 pm #158099This is how to get a comma-separated list of essay authors.
<pre><?php
$author_list = array();foreach ($authorArray as $author) {
$author_id = $author['id'];
$author_list[] = $author['name'];123// Pass the author ID into the new Pod. If you know the ID, then you don't need to use findRecords!$record1 = new Pod('author', $author_id);echo $record1->showTemplate('author_detail');}
// Here’s your list of author names
$author_list = implode(‘, ‘, $author_list);
echo ‘Authors: ‘ . $author_list;
?></pre> -
AuthorPosts
You must be logged in to reply to this topic.