jagguy Posted May 23, 2014 Share Posted May 23, 2014 ok I am getting an error over something simple, can anyone help Also how do i delete previous threads that I dont wont to continue? Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Post.user_id' in 'on clause'SQL Query: SELECT `Post`.`id`, `Post`.`title`, `Post`.`body`, `Post`.`created`, `Post`.`modified`, `User`.`two`, `User`.`three`, `User`.`id` FROM `jagguy`.`posts` AS `Post` LEFT JOIN `jagguy`.`users` AS `User` ON (`Post`.`user_id` = `User`.`id`) WHERE 1 = 1class User extends AppModel{public $hasMany = 'Post';}class Post extends AppModel{/*var $name='User';*/public $belongsTo = array('User');}controller////class PostsController extends AppController{public function home2(){$everything= $this->Post->find('all', array('contain' => array('User')));}view<?php foreach ($everything as $item):echo '<tr><td>'. $item['Post']['id']. '</td>';echo '<td>'. $item['Post']['title'].'</td>';echo '<td>'. $item['Post']['body'].'</td>'; Quote Link to comment https://forums.phpfreaks.com/topic/288702-2-tables-wont-display/ Share on other sites More sharing options...
Ch0cu3r Posted May 23, 2014 Share Posted May 23, 2014 The error is self explanatory. Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Post.user_id' in 'on clause' For the ON clause you are referring to a column called user_id from a table called Post in your database. MySQL cannot find that column in that table and this is why you are getting that error. Make sure you have supplied the correct table/column names. Also how do i delete previous threads that I dont wont to continue? You cannot delete topics/posts. Only admins/mods can delete topics/posts. We do not reponds to requests for topics/posts to be deleted unless they are against the forums Rules and ToS Quote Link to comment https://forums.phpfreaks.com/topic/288702-2-tables-wont-display/#findComment-1480573 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.