title
PHP OOP Login/Register System: Database Querying (Part 8/23)

description
Want more? Explore the library at https://www.codecourse.com/lessons Official site https://www.codecourse.com Twitter https://twitter.com/teamcodecourse

detail
{'title': 'PHP OOP Login/Register System: Database Querying (Part 8/23)', 'heatmap': [{'end': 235.065, 'start': 217.236, 'weight': 0.909}, {'end': 418.572, 'start': 402.222, 'weight': 0.734}, {'end': 542.806, 'start': 496.644, 'weight': 0.737}, {'end': 590.944, 'start': 564.387, 'weight': 0.761}, {'end': 1190.74, 'start': 1170.284, 'weight': 0.863}, {'end': 1265.967, 'start': 1218.47, 'weight': 0.765}], 'summary': 'Covers implementing a query method in a singleton database class for executing generic queries with parameters, securely querying a database using pdo, error handling in queries, and constructing dynamic sql queries to reduce the risk of sql injection, enhancing workflow efficiency and facilitating streamlined database operations.', 'chapters': [{'end': 236.607, 'segs': [{'end': 83.972, 'src': 'embed', 'start': 0.289, 'weight': 0, 'content': [{'end': 8.099, 'text': "Now that we've built our Singleton database class, we're going to move on to being able to query, fetch results and things like that.", 'start': 0.289, 'duration': 7.81}, {'end': 17.05, 'text': "So now we know that we've established a connection, we can go ahead and just create a generic query method.", 'start': 8.66, 'duration': 8.39}, {'end': 21.714, 'text': 'And basically what this is going to allow us to do is either publicly query it.', 'start': 17.751, 'duration': 3.963}, {'end': 31.441, 'text': 'So from our index.php, we could do something like query and then enter a query in here, say select username from users.', 'start': 21.854, 'duration': 9.587}, {'end': 37.465, 'text': 'So we can either do this or we can call it from with inside of our class from other methods.', 'start': 32.022, 'duration': 5.443}, {'end': 43.37, 'text': "So to define our method, we're just going to say public function query.", 'start': 38.306, 'duration': 5.064}, {'end': 46.592, 'text': 'And this is going to take two arguments.', 'start': 43.61, 'duration': 2.982}, {'end': 49.535, 'text': 'The first one is going to be the query string.', 'start': 46.873, 'duration': 2.662}, {'end': 57.06, 'text': 'The second is going to be an array of parameters that we might want to include as sort of binded values in PDO.', 'start': 49.895, 'duration': 7.165}, {'end': 60.523, 'text': 'Now what this allows us to do is firstly prepare the SQL.', 'start': 57.5, 'duration': 3.023}, {'end': 64.546, 'text': 'So prepare the string that we pass through.', 'start': 60.743, 'duration': 3.803}, {'end': 76.07, 'text': 'Instead of saying things like select username from users where username equals Alex, for example.', 'start': 65.746, 'duration': 10.324}, {'end': 83.972, 'text': 'Sorry, that will be just put some double quotes here.', 'start': 77.69, 'duration': 6.282}], 'summary': 'Developed a singleton database class with a query method to prepare and execute sql queries.', 'duration': 83.683, 'max_score': 0.289, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc289.jpg'}, {'end': 175.786, 'src': 'embed', 'start': 144.928, 'weight': 5, 'content': [{'end': 149.413, 'text': 'So the first thing to do here is reset the error back to false.', 'start': 144.928, 'duration': 4.485}, {'end': 152.877, 'text': 'Because remember, we can perform multiple queries one after another.', 'start': 149.493, 'duration': 3.384}, {'end': 154.878, 'text': "And it's likely that we're going to want to do that.", 'start': 153.197, 'duration': 1.681}, {'end': 161.921, 'text': 'For example, we might want to get a list of queries and then on the same page retrieve a query just for a specific user.', 'start': 154.938, 'duration': 6.983}, {'end': 170.364, 'text': "So we want to always reset the error back to false so that we know we're not returning an error for a previous query.", 'start': 162.321, 'duration': 8.043}, {'end': 175.786, 'text': 'So the next thing to do is basically just check if the query has been prepared properly.', 'start': 171.165, 'duration': 4.621}], 'summary': 'Reset error to false before multiple queries. check query preparation.', 'duration': 30.858, 'max_score': 144.928, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc144928.jpg'}, {'end': 235.065, 'src': 'heatmap', 'start': 187.292, 'weight': 3, 'content': [{'end': 196.717, 'text': "Otherwise we're just going to go ahead and execute the query, return the results as an object and then update the row count in our class up here,", 'start': 187.292, 'duration': 9.425}, {'end': 198.858, 'text': 'so the count of results, and then set the results.', 'start': 196.717, 'duration': 2.141}, {'end': 203.884, 'text': 'So in here we say if this underscore query.', 'start': 199.578, 'duration': 4.306}, {'end': 212.376, 'text': "Now what we're doing is we're performing an assignment to a variable and also checking this within an if statement anyway.", 'start': 204.505, 'duration': 7.871}, {'end': 214.88, 'text': 'So this PDO.', 'start': 212.937, 'duration': 1.943}, {'end': 219.257, 'text': 'Prepare SQL.', 'start': 217.236, 'duration': 2.021}, {'end': 224.019, 'text': "So if that's successful, I'm just going to echo out success.", 'start': 220.037, 'duration': 3.982}, {'end': 226.019, 'text': "So let's go ahead and just take a look at this.", 'start': 224.619, 'duration': 1.4}, {'end': 227.06, 'text': "Let's refresh.", 'start': 226.439, 'duration': 0.621}, {'end': 228.3, 'text': 'It says success.', 'start': 227.48, 'duration': 0.82}, {'end': 233.182, 'text': "Let's actually get rid of the connected message that we included in the last part.", 'start': 228.68, 'duration': 4.502}, {'end': 235.065, 'text': "And let's go ahead and just refresh.", 'start': 233.803, 'duration': 1.262}], 'summary': 'The transcript discusses executing a query, updating row count, and checking for success in a pdo prepare sql operation.', 'duration': 31.965, 'max_score': 187.292, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc187292.jpg'}], 'start': 0.289, 'title': 'Database query execution', 'summary': 'Covers implementing a query method in a singleton database class to execute generic queries with parameters, facilitating dynamic data retrieval and manipulation. it also discusses executing and preparing queries in php using pdo, emphasizing error handling, query preparation, execution, and row count updates.', 'chapters': [{'end': 118.141, 'start': 0.289, 'title': 'Implementing query method in singleton database class', 'summary': 'Covers the implementation of a query method in a singleton database class, enabling the execution of generic queries with binded parameters, facilitating dynamic data retrieval and manipulation.', 'duration': 117.852, 'highlights': ['The query method allows for the execution of generic queries with binded parameters, enhancing the flexibility and security of data retrieval and manipulation.', 'The method takes two arguments: the query string and an array of parameters, offering a dynamic and customizable approach to querying the database.', 'By preparing the SQL string and using question marks as placeholders for binded values, the method enables the secure and dynamic execution of queries, enhancing the robustness of the database class.']}, {'end': 236.607, 'start': 118.501, 'title': 'Php query execution', 'summary': 'Discusses the process of executing and preparing queries in php using pdo, emphasizing the importance of resetting errors, preparing the query, and executing it successfully while handling parameters and row count updates.', 'duration': 118.106, 'highlights': ['The importance of resetting errors back to false before performing multiple queries is emphasized, ensuring that errors from previous queries do not affect the current one.', 'The process of preparing queries in PDO is explained, including the successful binding of parameters if they exist and the execution of the query, returning results as an object while updating the row count.', 'The concept of executing and preparing queries in PHP using PDO and the significance of ensuring the proper preparation of queries and successful execution are highlighted.']}], 'duration': 236.318, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc289.jpg', 'highlights': ['The query method allows for the execution of generic queries with binded parameters, enhancing the flexibility and security of data retrieval and manipulation.', 'The method takes two arguments: the query string and an array of parameters, offering a dynamic and customizable approach to querying the database.', 'By preparing the SQL string and using question marks as placeholders for binded values, the method enables the secure and dynamic execution of queries, enhancing the robustness of the database class.', 'The process of preparing queries in PDO is explained, including the successful binding of parameters if they exist and the execution of the query, returning results as an object while updating the row count.', 'The concept of executing and preparing queries in PHP using PDO and the significance of ensuring the proper preparation of queries and successful execution are highlighted.', 'The importance of resetting errors back to false before performing multiple queries is emphasized, ensuring that errors from previous queries do not affect the current one.']}, {'end': 496.383, 'segs': [{'end': 434.923, 'src': 'heatmap', 'start': 402.222, 'weight': 0.734, 'content': [{'end': 408.065, 'text': 'So this is the actual success of whether the query has been successfully executed rather than prepared.', 'start': 402.222, 'duration': 5.843}, {'end': 410.547, 'text': 'So in this case, it is a success.', 'start': 408.526, 'duration': 2.021}, {'end': 418.572, 'text': "If we then go ahead and change this, like I showed in the last example, to users with a Z, the success message doesn't appear,", 'start': 411.187, 'duration': 7.385}, {'end': 421.294, 'text': "because the users table with a Z obviously doesn't exist.", 'start': 418.572, 'duration': 2.722}, {'end': 423.415, 'text': "So, now that we've done that,", 'start': 422.094, 'duration': 1.321}, {'end': 434.923, 'text': "we've basically built the functionality to query a database securely by binding parameters and removing the possibility of SQL injections.", 'start': 423.415, 'duration': 11.508}], 'summary': 'Successfully implemented secure database querying with parameter binding to prevent sql injections.', 'duration': 32.701, 'max_score': 402.222, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc402222.jpg'}, {'end': 496.383, 'src': 'embed', 'start': 418.572, 'weight': 0, 'content': [{'end': 421.294, 'text': "because the users table with a Z obviously doesn't exist.", 'start': 418.572, 'duration': 2.722}, {'end': 423.415, 'text': "So, now that we've done that,", 'start': 422.094, 'duration': 1.321}, {'end': 434.923, 'text': "we've basically built the functionality to query a database securely by binding parameters and removing the possibility of SQL injections.", 'start': 423.415, 'duration': 11.508}, {'end': 437.665, 'text': 'This is functionality native to PDO.', 'start': 434.983, 'duration': 2.682}, {'end': 440.848, 'text': "We've just abstracted it to make it a bit easier for us to work with.", 'start': 437.685, 'duration': 3.163}, {'end': 448.151, 'text': 'So in this case, if the query has executed successfully, what do we want to do? Well, we want to store the result set.', 'start': 441.508, 'duration': 6.643}, {'end': 454.713, 'text': 'So we just say this results equals this query.', 'start': 448.511, 'duration': 6.202}, {'end': 456.474, 'text': "Remember, we've stored the query here.", 'start': 454.733, 'duration': 1.741}, {'end': 464.501, 'text': "FetchAll, so that's a method of PDO, and we want to define or say that we want to fetch the object of results.", 'start': 457.214, 'duration': 7.287}, {'end': 467.984, 'text': "This is important because we're working with objects or into program.", 'start': 464.921, 'duration': 3.063}, {'end': 469.725, 'text': "It doesn't make sense to return an array.", 'start': 468.004, 'duration': 1.721}, {'end': 471.207, 'text': 'We want to work with an object.', 'start': 470.066, 'duration': 1.141}, {'end': 478.874, 'text': 'We want the values in the columns of our table to represent as an object.', 'start': 471.287, 'duration': 7.587}, {'end': 480.915, 'text': 'We also want to update the count.', 'start': 479.494, 'duration': 1.421}, {'end': 483.337, 'text': 'of results that we get back.', 'start': 482.116, 'duration': 1.221}, {'end': 489.34, 'text': "And that's basically just as simple as saying this query row count.", 'start': 483.737, 'duration': 5.603}, {'end': 491.161, 'text': "That's a method on PDO as well.", 'start': 489.42, 'duration': 1.741}, {'end': 496.383, 'text': "So otherwise, we want to go ahead and set the fact that there's been an error.", 'start': 492.101, 'duration': 4.282}], 'summary': 'Built secure database query functionality, using pdo to prevent sql injections. results are stored as objects, with row count updated. error handling included.', 'duration': 77.811, 'max_score': 418.572, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc418572.jpg'}], 'start': 237.028, 'title': 'Pdo database querying', 'summary': 'Covers securely querying a database using pdo, including preparing and executing queries, binding parameters, and avoiding sql injections. it also explains storing query results in pdo, using fetchall method to fetch object results and updating the count of results with query rowcount method.', 'chapters': [{'end': 440.848, 'start': 237.028, 'title': 'Secure database querying with pdo', 'summary': 'Demonstrates the process of securely querying a database using pdo, including preparing and executing queries, binding parameters, and avoiding sql injections.', 'duration': 203.82, 'highlights': ['Prepared and executed queries with successful outcomes are demonstrated, showing the functionality of querying a database securely using PDO.', 'The process of binding parameters to the query to prevent SQL injections is explained, highlighting the importance of parameter binding for secure database querying.', 'The necessity of checking if the users table exists before executing a query is emphasized to avoid errors and ensure successful database interactions.']}, {'end': 496.383, 'start': 441.508, 'title': 'Storing query results in pdo', 'summary': 'Explains how to store query results in pdo, including using fetchall method to fetch object results and updating the count of results with query rowcount method.', 'duration': 54.875, 'highlights': ['Using fetchAll method of PDO to fetch object results from a query, aiming to work with object values instead of an array.', 'Updating the count of results by using the query rowCount method, provided by PDO.']}], 'duration': 259.355, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc237028.jpg', 'highlights': ['Prepared and executed queries with successful outcomes are demonstrated, showing the functionality of querying a database securely using PDO.', 'The process of binding parameters to the query to prevent SQL injections is explained, highlighting the importance of parameter binding for secure database querying.', 'The necessity of checking if the users table exists before executing a query is emphasized to avoid errors and ensure successful database interactions.', 'Using fetchAll method of PDO to fetch object results from a query, aiming to work with object values instead of an array.', 'Updating the count of results by using the query rowCount method, provided by PDO.']}, {'end': 856.03, 'segs': [{'end': 526.389, 'src': 'embed', 'start': 496.644, 'weight': 0, 'content': [{'end': 498.905, 'text': 'So this error equals true.', 'start': 496.644, 'duration': 2.261}, {'end': 506.589, 'text': "Now, we've not actually got a way to define whether this query has successfully executed or not.", 'start': 499.645, 'duration': 6.944}, {'end': 510.231, 'text': "So we're going to go ahead and create a public function called error.", 'start': 507.029, 'duration': 3.202}, {'end': 514.84, 'text': "And all we're going to basically do here is just return this error.", 'start': 511.277, 'duration': 3.563}, {'end': 517.302, 'text': 'So that will by default return false.', 'start': 515.36, 'duration': 1.942}, {'end': 521.005, 'text': 'If there has been an error, though, this method will return true.', 'start': 517.642, 'duration': 3.363}, {'end': 526.389, 'text': 'So what we can now do is start to get into a bit more useful functionality and say user equals.', 'start': 521.424, 'duration': 4.965}], 'summary': 'Creating a public function to define query execution success, returning true for error and false by default.', 'duration': 29.745, 'max_score': 496.644, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc496644.jpg'}, {'end': 542.806, 'src': 'heatmap', 'start': 496.644, 'weight': 0.737, 'content': [{'end': 498.905, 'text': 'So this error equals true.', 'start': 496.644, 'duration': 2.261}, {'end': 506.589, 'text': "Now, we've not actually got a way to define whether this query has successfully executed or not.", 'start': 499.645, 'duration': 6.944}, {'end': 510.231, 'text': "So we're going to go ahead and create a public function called error.", 'start': 507.029, 'duration': 3.202}, {'end': 514.84, 'text': "And all we're going to basically do here is just return this error.", 'start': 511.277, 'duration': 3.563}, {'end': 517.302, 'text': 'So that will by default return false.', 'start': 515.36, 'duration': 1.942}, {'end': 521.005, 'text': 'If there has been an error, though, this method will return true.', 'start': 517.642, 'duration': 3.363}, {'end': 526.389, 'text': 'So what we can now do is start to get into a bit more useful functionality and say user equals.', 'start': 521.424, 'duration': 4.965}, {'end': 531.013, 'text': 'And then we want to say if user error.', 'start': 527.009, 'duration': 4.004}, {'end': 539.602, 'text': 'Echo no user, otherwise echo OK.', 'start': 533.354, 'duration': 6.248}, {'end': 542.806, 'text': "OK, so let's go ahead and test this out.", 'start': 539.942, 'duration': 2.864}], 'summary': 'Created a public function to return error status; tested functionality.', 'duration': 46.162, 'max_score': 496.644, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc496644.jpg'}, {'end': 669.011, 'src': 'heatmap', 'start': 564.387, 'weight': 1, 'content': [{'end': 565.808, 'text': 'So we want to say return this.', 'start': 564.387, 'duration': 1.421}, {'end': 569.092, 'text': "Now, basically, all that's going to do is return the current object we're working with.", 'start': 565.868, 'duration': 3.224}, {'end': 572.314, 'text': 'and therefore allow us to chain on this error method here.', 'start': 569.492, 'duration': 2.822}, {'end': 574.535, 'text': 'So when we refresh now, it says OK.', 'start': 572.714, 'duration': 1.821}, {'end': 584.42, 'text': 'If we were to go and modify the query as we have done before to say users with a Z, we then get the no user error.', 'start': 575.215, 'duration': 9.205}, {'end': 590.944, 'text': "So we now basically have the ability to query, check whether there's an error or not, and well, that's it really.", 'start': 584.801, 'duration': 6.143}, {'end': 594.906, 'text': 'brilliant. what we need.', 'start': 592.865, 'duration': 2.041}, {'end': 599.728, 'text': "so what we're now going to do is start to look at how we can define.", 'start': 594.906, 'duration': 4.822}, {'end': 612.854, 'text': 'this is sort of not strictly required, but it makes it a lot easier to delete things quicker, get things quicker and all that sort of stuff.', 'start': 599.728, 'duration': 13.126}, {'end': 619.297, 'text': "so we're going to create a method called action, And this is going to allow us to perform a specific action.", 'start': 612.854, 'duration': 6.443}, {'end': 623.018, 'text': 'So it will be something like select or delete.', 'start': 619.477, 'duration': 3.541}, {'end': 625.158, 'text': "And we're going to define a table.", 'start': 623.798, 'duration': 1.36}, {'end': 628.819, 'text': "And then we're going to define a specific field with a specific value.", 'start': 625.378, 'duration': 3.441}, {'end': 635.581, 'text': 'So this can be, does it equal? Is it greater than? So what we can then do is start to change this functionality.', 'start': 628.879, 'duration': 6.702}, {'end': 639.362, 'text': 'And we could say something like the database we want to get.', 'start': 636.221, 'duration': 3.141}, {'end': 641.542, 'text': "And we've already looked at this already.", 'start': 639.742, 'duration': 1.8}, {'end': 644.063, 'text': "We've already looked at how this might work.", 'start': 641.602, 'duration': 2.461}, {'end': 653.566, 'text': 'so we want to get from the users table where username is equal to alex.', 'start': 644.483, 'duration': 9.083}, {'end': 655.486, 'text': 'so we want to define functionality like this,', 'start': 653.566, 'duration': 1.92}, {'end': 661.728, 'text': 'and the reason being is that you can clearly see it makes it a lot easier than performing a raw query on the database,', 'start': 655.486, 'duration': 6.242}, {'end': 667.01, 'text': 'passing in the values that you want to bind, So this just abstracts things even more.', 'start': 661.728, 'duration': 5.282}, {'end': 669.011, 'text': "So we don't even have to bother writing queries.", 'start': 667.03, 'duration': 1.981}], 'summary': 'Implementing a method to perform specific actions, enabling easier database queries and abstraction.', 'duration': 116.157, 'max_score': 564.387, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc564387.jpg'}], 'start': 496.644, 'title': 'Query error handling and action method', 'summary': 'Covers implementing error handling in queries, creating a public function for query success, enabling chaining to check for errors, and creating an action method for specific database actions like select or delete, enhancing workflow efficiency.', 'chapters': [{'end': 599.728, 'start': 496.644, 'title': 'Chaining error handling in queries', 'summary': 'Discusses the implementation of error handling in queries, creating a public function to define query success, and enabling chaining to check for errors, allowing the user to determine query success.', 'duration': 103.084, 'highlights': ['The chapter discusses the implementation of error handling in queries, creating a public function to define query success, and enabling chaining to check for errors, allowing the user to determine query success.', 'The method returns true if there has been an error, providing a clear indication of query success or failure.', 'The implementation enables the ability to query and check for errors, enhancing the functionality of the code.']}, {'end': 856.03, 'start': 599.728, 'title': 'Database action method', 'summary': 'Discusses the creation of an action method to perform specific actions like select or delete on a database table, abstracting queries, and enhancing workflow efficiency by defining and extracting field values and operators.', 'duration': 256.302, 'highlights': ['The chapter discusses the creation of an action method to perform specific actions like select or delete on a database table', 'Abstracting queries and enhancing workflow efficiency by defining and extracting field values and operators.', 'Defining specific field with a specific value, such as equals, greater than, etc.']}], 'duration': 359.386, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc496644.jpg', 'highlights': ['The chapter covers implementing error handling in queries and creating a public function for query success.', 'Enabling chaining to check for errors enhances workflow efficiency.', 'The method returns true if there has been an error, providing a clear indication of query success or failure.', 'The implementation enables the ability to query and check for errors, enhancing the functionality of the code.', 'The chapter discusses the creation of an action method for specific database actions like select or delete.', 'Abstracting queries enhances workflow efficiency by defining and extracting field values and operators.', 'Defining specific field with a specific value, such as equals, greater than, etc.']}, {'end': 1345.189, 'segs': [{'end': 983.519, 'src': 'embed', 'start': 955.604, 'weight': 0, 'content': [{'end': 965.27, 'text': 'what we then want to do is use our query to perform a query, a query method to perform a query, sorry.', 'start': 955.604, 'duration': 9.666}, {'end': 971.233, 'text': 'So we want to say if SQL, and then we want to bind on the value.', 'start': 965.811, 'duration': 5.422}, {'end': 973.915, 'text': 'So the value here will be bound to this.', 'start': 971.693, 'duration': 2.222}, {'end': 976.356, 'text': 'The query will be run here.', 'start': 974.675, 'duration': 1.681}, {'end': 980.318, 'text': 'And this question mark will be replaced with the value that we pass in here.', 'start': 976.896, 'duration': 3.422}, {'end': 983.519, 'text': "So we're basically making use of everything in tangent.", 'start': 980.838, 'duration': 2.681}], 'summary': 'Using query method to perform sql queries with value binding.', 'duration': 27.915, 'max_score': 955.604, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc955604.jpg'}, {'end': 1055.461, 'src': 'embed', 'start': 1015.39, 'weight': 2, 'content': [{'end': 1018.491, 'text': "has successfully run, we want to return the current object we're in.", 'start': 1015.39, 'duration': 3.101}, {'end': 1023.133, 'text': "Because later on, we're going to create a method that allows us to return the result set.", 'start': 1018.811, 'duration': 4.322}, {'end': 1026.733, 'text': "So in this case, we're not returning any results or anything like that.", 'start': 1024.053, 'duration': 2.68}, {'end': 1031.556, 'text': "All we're doing is just saying no user or OK, for example.", 'start': 1026.973, 'duration': 4.583}, {'end': 1037.082, 'text': "So now that what we want to do is we'll go ahead and build our get and delete methods.", 'start': 1032.617, 'duration': 4.465}, {'end': 1042.647, 'text': 'Now, these are extremely easy because all these are going to do is make use of this of this action here.', 'start': 1037.242, 'duration': 5.405}, {'end': 1048.494, 'text': "In actual fact, this could probably be private because there's no real need to use this outside of our database.", 'start': 1042.988, 'duration': 5.506}, {'end': 1050.016, 'text': "If you want to, that's fine.", 'start': 1048.815, 'duration': 1.201}, {'end': 1055.461, 'text': "So for get, what do we need to do? Well, if you're a little confused, this might clear things up for you.", 'start': 1050.817, 'duration': 4.644}], 'summary': 'Building get and delete methods using the current object, with a potential for the action to be made private.', 'duration': 40.071, 'max_score': 1015.39, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc1015390.jpg'}, {'end': 1201.528, 'src': 'heatmap', 'start': 1170.284, 'weight': 0.863, 'content': [{'end': 1172.906, 'text': "But we're just here saying delete.", 'start': 1170.284, 'duration': 2.622}, {'end': 1174.047, 'text': "And that's it.", 'start': 1173.467, 'duration': 0.58}, {'end': 1179.912, 'text': "So now when we run get here, let's go ahead and have a look.", 'start': 1174.547, 'duration': 5.365}, {'end': 1180.973, 'text': 'Refresh OK.', 'start': 1180.252, 'duration': 0.721}, {'end': 1190.74, 'text': "So we now know that we have a set of results from this get method, because that's called action, which is called query,", 'start': 1181.653, 'duration': 9.087}, {'end': 1196.104, 'text': 'which has then set the results up here to whatever the result set is.', 'start': 1190.74, 'duration': 5.364}, {'end': 1201.528, 'text': 'So if we were to go ahead and change this to Billy, there is no user called Billy in the table at the moment.', 'start': 1196.684, 'duration': 4.844}], 'summary': "Demonstrating a 'delete' action and querying for results.", 'duration': 31.244, 'max_score': 1170.284, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc1170284.jpg'}, {'end': 1242.248, 'src': 'embed', 'start': 1218.47, 'weight': 4, 'content': [{'end': 1226.532, 'text': "So once we start to use our count method, we'll be able to check if this has actually returned anything or not.", 'start': 1218.47, 'duration': 8.062}, {'end': 1229.252, 'text': "So let's go ahead and just build our count method very quickly.", 'start': 1226.912, 'duration': 2.34}, {'end': 1230.812, 'text': 'This is extremely easy.', 'start': 1229.312, 'duration': 1.5}, {'end': 1232.613, 'text': 'So public function count.', 'start': 1230.892, 'duration': 1.721}, {'end': 1238.226, 'text': "Now, in this case, this is just going to be, we're going to use this here instead.", 'start': 1234.025, 'duration': 4.201}, {'end': 1239.787, 'text': 'So count.', 'start': 1238.346, 'duration': 1.441}, {'end': 1242.248, 'text': "We'll just say if no count.", 'start': 1240.947, 'duration': 1.301}], 'summary': 'Building a count method to check returned values.', 'duration': 23.778, 'max_score': 1218.47, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc1218470.jpg'}, {'end': 1265.967, 'src': 'heatmap', 'start': 1218.47, 'weight': 0.765, 'content': [{'end': 1226.532, 'text': "So once we start to use our count method, we'll be able to check if this has actually returned anything or not.", 'start': 1218.47, 'duration': 8.062}, {'end': 1229.252, 'text': "So let's go ahead and just build our count method very quickly.", 'start': 1226.912, 'duration': 2.34}, {'end': 1230.812, 'text': 'This is extremely easy.', 'start': 1229.312, 'duration': 1.5}, {'end': 1232.613, 'text': 'So public function count.', 'start': 1230.892, 'duration': 1.721}, {'end': 1238.226, 'text': "Now, in this case, this is just going to be, we're going to use this here instead.", 'start': 1234.025, 'duration': 4.201}, {'end': 1239.787, 'text': 'So count.', 'start': 1238.346, 'duration': 1.441}, {'end': 1242.248, 'text': "We'll just say if no count.", 'start': 1240.947, 'duration': 1.301}, {'end': 1248.53, 'text': 'And all this is going to do is very, very similar to error is return this count.', 'start': 1242.848, 'duration': 5.682}, {'end': 1249.77, 'text': "And that's it.", 'start': 1249.31, 'duration': 0.46}, {'end': 1256.212, 'text': "So now when we refresh, we get no user because we're looking for a user called Billy that doesn't exist in our database.", 'start': 1250.35, 'duration': 5.862}, {'end': 1260.094, 'text': 'But if we were to say Alex, then we will get an OK message.', 'start': 1256.552, 'duration': 3.542}, {'end': 1265.967, 'text': "Oh, sorry, we haven't even created anything in Alex.", 'start': 1262.665, 'duration': 3.302}], 'summary': 'Creating a count method to check for user existence in the database. demonstrates usage of the count method and returns based on user search.', 'duration': 47.497, 'max_score': 1218.47, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc1218470.jpg'}], 'start': 856.51, 'title': 'Constructing dynamic sql queries and database query methods', 'summary': "Explains constructing dynamic sql queries using strings and binding values to reduce the risk of sql injection, with an example of constructing a 'select' query. it also covers the implementation of 'get' and 'delete' methods for streamlined database operations, demonstrating usage examples and their advantages.", 'chapters': [{'end': 1014.476, 'start': 856.51, 'title': 'Building dynamic sql queries', 'summary': "Explains how to construct dynamic sql queries by using a string and binding values, enabling flexibility and reducing the risk of sql injection, with an example of constructing a 'select' query with a bound parameter.", 'duration': 157.966, 'highlights': ['Constructing dynamic SQL queries by using a string and binding values', "Example of constructing a 'select' query with a bound parameter"]}, {'end': 1345.189, 'start': 1015.39, 'title': 'Database query methods', 'summary': "Covers the implementation of 'get' and 'delete' methods for retrieving and deleting data from the database, demonstrating usage examples and explaining the advantages of utilizing these methods for streamlined database operations.", 'duration': 329.799, 'highlights': ["The 'get' method is implemented for retrieving data from the database, using a simplified approach to select all fields from the specified table based on the provided conditions, enhancing efficiency in database operations.", "The 'delete' method is introduced, showcasing its simplicity and effectiveness in removing data from the database, contributing to streamlined database management.", "The 'count' method is briefly discussed, highlighting its usage for determining the number of results returned from database queries, enhancing data validation and error handling."]}], 'duration': 488.679, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/PaBWDOBFxDc/pics/PaBWDOBFxDc856510.jpg', 'highlights': ["Example of constructing a 'select' query with a bound parameter", 'Constructing dynamic SQL queries by using a string and binding values', "The 'get' method is implemented for retrieving data from the database, enhancing efficiency", "The 'delete' method is introduced, showcasing its simplicity and effectiveness", "The 'count' method is briefly discussed, enhancing data validation"]}], 'highlights': ['The query method allows for the execution of generic queries with binded parameters, enhancing the flexibility and security of data retrieval and manipulation.', 'The method takes two arguments: the query string and an array of parameters, offering a dynamic and customizable approach to querying the database.', 'By preparing the SQL string and using question marks as placeholders for binded values, the method enables the secure and dynamic execution of queries, enhancing the robustness of the database class.', 'Prepared and executed queries with successful outcomes are demonstrated, showing the functionality of querying a database securely using PDO.', 'The process of binding parameters to the query to prevent SQL injections is explained, highlighting the importance of parameter binding for secure database querying.', 'The necessity of checking if the users table exists before executing a query is emphasized to avoid errors and ensure successful database interactions.', 'The chapter covers implementing error handling in queries and creating a public function for query success.', 'Enabling chaining to check for errors enhances workflow efficiency.', "Example of constructing a 'select' query with a bound parameter", 'Constructing dynamic SQL queries by using a string and binding values']}