@CamiloSanchez1979 You only need to specify the Model.field if you are wanting to do a condition search where you are checking if something is equal to, less than, etc or if you are wanting to specify which fields should be returned from the query. You do this by passing in an array as the second param to the find method. In this video we are wanting to find all posts and have no conditions to be met. Thus we only need to pass in the type of the find query.
i did the brackets and it worked fine but the index wont show in the view in my browser .. it shows blank page........ any way i'll recheck my code again
@goldd85 I'm sorry I don't know how to help you with this one. You must have done something wrong. Writing a foreach loop is very simple, no one else has had this problem. All I can suggest is recheck your code or try writing the foreach loop the normal way rather than using the shorthand way (ex. Use curly brackets {} and not the : colon syntax)
@runrunforest1 It's a continuation of the previous 2 videos. You don't need to see the model in order to use it's find method. The model is completely blank at this point anyways besides just declaring it as a class.
@andrewperk i got this error when i try to view all messages. i dont have the server locally but i will try to config it and check. min [5:31]
i find this post cakephp.1045679.n5.nabble.com/2-0-0-dev-sturtup-problem-td3322343.html and tried to update cake to version 2.0 but that doesn't work.
Hello Andrew..your tutorials are great...Instead of using find(), can we directly use select query and fetch the data to display it in views.I am having difficulty as i need to combine 5 tables using join to display the data.So i directly used select query. eg.
Thank you for getting back to me, I Tried it both ways and even went to your site and downloaded to the Source code. Its very strange. Won't connect to the DB although the cake config page says it can. I am using wamp if it makes any difference. is there some place I can post my code for you to look at or perhaps I could post it on my site. Would rather just email it if I could. But I understand if you would rather not.
@kazigmal Hard to say without myself being able to look at it. But maybe you used a semicolon using the different foreach syntax. In the statement where I say foreach($posts as $post): That should be a colon not a semicolon. In the video it's hard to tell what it is. Make sure you referencing the $post variable now inside the foreach loop rather than $posts.
Using the endforeach; requires that you have short tags enabled in your php .ini file. You probably have it disabled. Using foreach with braces works just fine too, you can either one you feel comfortable with.
wow, this is a great tutorial! very clear and understandable with good contextual information so i understand exactly what you are doing. i am very impressed and looking forward to learning more methods from you!
This has been flagged as spam show
Thanks mate, I was quite desperate trying to understand how properly use find(). You made everything look pretty easy. Props to you! :)
StorRm371 3 weeks ago
Thanks mate, I was quite desperate trying to understand how properly use find(). You made everything look pretty easy. Props to you! :)
StorRm371 3 weeks ago
Andrew, the docs say to use the form Modelname.fieldname, does it make any particular difference? Thanks
CamiloSanchez1979 7 months ago
@CamiloSanchez1979 You only need to specify the Model.field if you are wanting to do a condition search where you are checking if something is equal to, less than, etc or if you are wanting to specify which fields should be returned from the query. You do this by passing in an array as the second param to the find method. In this video we are wanting to find all posts and have no conditions to be met. Thus we only need to pass in the type of the find query.
andrewperk 7 months ago
nice tutorial thanks..^^
mydreamcode19 8 months ago
i did the brackets and it worked fine but the index wont show in the view in my browser .. it shows blank page........ any way i'll recheck my code again
thanx very much for ur help sir i appreciate it
god bless u :)
goldd85 8 months ago
i did everything u said ...but nothing shows in the view in web browser ... and it gives me an error in line of endforeach;
thats is :)
goldd85 8 months ago 2
@goldd85 I'm sorry I don't know how to help you with this one. You must have done something wrong. Writing a foreach loop is very simple, no one else has had this problem. All I can suggest is recheck your code or try writing the foreach loop the normal way rather than using the shorthand way (ex. Use curly brackets {} and not the : colon syntax)
andrewperk 8 months ago
have an error in endforeach statement....what is the solution??
goldd85 8 months ago
@goldd85 I have no way to provide you a solution since you did not provide an error.
andrewperk 8 months ago 2
marvelous video :)
mora88marmora 9 months ago
You didn't show your model in this video
runrunforest1 10 months ago
@runrunforest1 It's a continuation of the previous 2 videos. You don't need to see the model in order to use it's find method. The model is completely blank at this point anyways besides just declaring it as a class.
andrewperk 10 months ago
Hi dude. i have a problem. im already check all the code againts yours... it's exactly the same but i got this message
Fatal error: Call to a member function getAttribute() on a non-object
i can`t find a solution, maybe my php config is the problem, my server is on dreamhost.
Can you give me a tip?
fullmentalmx 1 year ago
@fullmentalmx At what point did you get this error? Did the code from video #2 work on your server? Does this work locally for you?
andrewperk 1 year ago
@andrewperk i got this error when i try to view all messages. i dont have the server locally but i will try to config it and check. min [5:31]
i find this post cakephp.1045679.n5.nabble.com/2-0-0-dev-sturtup-problem-td3322343.html and tried to update cake to version 2.0 but that doesn't work.
fullmentalmx 1 year ago
Hello Andrew..your tutorials are great...Instead of using find(), can we directly use select query and fetch the data to display it in views.I am having difficulty as i need to combine 5 tables using join to display the data.So i directly used select query. eg.
$sql="select id,name,email from users";
$posts= $this->Post->query($query); $this->set('posts',$posts);
when i gave this i got an error in the views....
Undefined index: Post [APP\views\posts\index.ctp, line 27] can you explain that?
caribeansong 1 year ago
Thank you for getting back to me, I Tried it both ways and even went to your site and downloaded to the Source code. Its very strange. Won't connect to the DB although the cake config page says it can. I am using wamp if it makes any difference. is there some place I can post my code for you to look at or perhaps I could post it on my site. Would rather just email it if I could. But I understand if you would rather not.
kazigmal 1 year ago
I am having trouble...
I am getting the following error:
Parse error: parse error in ~\tut_blog\app\views\posts\index.ctp on line 10
Can't seem to see what i did wrong
kazigmal 1 year ago 2
@kazigmal Hard to say without myself being able to look at it. But maybe you used a semicolon using the different foreach syntax. In the statement where I say foreach($posts as $post): That should be a colon not a semicolon. In the video it's hard to tell what it is. Make sure you referencing the $post variable now inside the foreach loop rather than $posts.
andrewperk 1 year ago
I figured it out... It seems that the problem was with my PHP environment... I did not enable short tags...
Once I did... everthing was fine.
kazigmal 1 year ago
This has been flagged as spam show
Why the following code is not able to produce the desire result when i changed the "Post to post" ?
uppercase to lowercase
$this->post->find('all')
yewei123sg 1 year ago
Why the following code is not able to produce the desire result when i changed the "Post to post" ?
uppercase to lowercase
$this->post->find('all')
yewei123sg 1 year ago
@yewei123sg That's just how it is, it requires it to be capitalized when referring to a models method.
andrewperk 1 year ago
thanks for posting this video
sivayuvasamrat 1 year ago
foreach () ... endforeach does not work..
i did it this way and it worked..
forearch () {
}
can u explain why this is so?
erhmirhnem 1 year ago
@erhmirhnem
Using the endforeach; requires that you have short tags enabled in your php .ini file. You probably have it disabled. Using foreach with braces works just fine too, you can either one you feel comfortable with.
andrewperk 1 year ago
@andrewperk .. thanks soo much.. ur da mayne... stay blessed...
erhmirhnem 1 year ago
Consise, understable, easy, quick.... its all i want in a vid tut. Perfect
zarnos 1 year ago
I like them too.Indeed, it's very clear and fast tutorial I ever seen.Thanks man
ucha19871 1 year ago
Believe me, you'll become a legend. Congrats.
BettyBoop186 1 year ago
wow, this is a great tutorial! very clear and understandable with good contextual information so i understand exactly what you are doing. i am very impressed and looking forward to learning more methods from you!
yagazuzy 1 year ago 6
@yagazuzy Thanks, I'm glad you liked it. I should have part 4 up tonight or early tomorrow.
andrewperk 1 year ago