Search the Community
Showing results for tags 'query'.
-
I'm not sure how the second part of this example is related to the first, and where it belongs. I am quoting from page 174 of YiiBook2: # models/Page.php public function getUser() { return $this->hasOne(User::className(), ['id' => 'user_id']); } This means you can fetch every page with every page author in one step: $pages = Page::find()->with('user')->all(); I'm guessing that with('user') calls the getUser method. Is that right? But in which file does the second part of the example belong? In the view file?
- 1 reply
-
- getuser
- with(user)
-
(and 4 more)
Tagged with:
-
I am new to using PHP and MySQL. Previously used MS Access. One ability in creating a query in Access was very helpful to me. I am asking if something like it is available in PHP-MySQL. Here is a query designed for use in MS Access: ------------ SELECT tblCourses.[ClassID], tblCourses.[Coursename], tblCourses.[TeaLastname], tblCourses.[TeaFirstname] FROM tblCourses WHERE (((tblCourses.[TeaLastname])=[Enter teacher's last name:])); ------------ This query allowed the user of the query to input a teacher's last name and then receive all the data for the courses taught by that teacher. Can anyone tell me how to accomplish this using PHP and MySQL? I would appreciate any guidance or assistance. Thank you. Wes Smith
-
My brain must be dead, because while I read the book, I am having trouble devising a solution to this problem. I would like to include a button on a page of query results that allows users to filter the results to those that match only certain criteria. I realize that it's not a good idea to run a whole new query just for this filtering, so I have been trying to look for a solution, but to no avail. Any tips? I'm sorry for being vague, I'd just rather not give away too much about the site's structure. Thank you!
-
Version 0.5 Page 167 Quote: "// Works safely: $model = Page::model()->find('id=:id', array(':id'=>$id));" Larry, What exactly does the colon do? What does the array do? I know they make the query safer, but how? Thanks.
- 1 reply
-
- retrieving
- record
-
(and 2 more)
Tagged with:
-
On line 33 it reads: $words = FALSE; // Flag variable - Why is this needed? Why false boolean? On line 37 it reads: $r = msyqli_query($dbc, $q); if (mysqli_num_rows($r) == 1) { $words = mysqli_fetch_array($r, MYSQLI_ASSOC); } - Is this common practice, to check to see if there is at least one result returned from the query? In some scripts, this is included and then in some it is. For example go to line 47 of the same script, when the array is fetched the function isn't wrapped in the same way as above. Line 46, 47: $r = msyqli_query($dbc, $q); $r = mysqli_fetch_array($r, MYSQLI_ASSOC);
- 2 replies
-
- message board
- query
-
(and 1 more)
Tagged with: