Having spent the majority of this year programming a custom reporting dashboard for my employer written in PHP and MySQL, it is an understatement to say that I have learned a lot. Nothing beats real-world experience and I really have come into my own with PHP, learning more and more daily as I continue progressing forward on my goal of becoming a Back-End Web Developer. I have written several PHP-related posts this year and wanted to provide them all in one easy-to-access list. Enjoy! [Keep reading for more MySQL database and Python/PHP-centric content >>>]
open-source
ROW_NUMBER() Window Function – find duplicate values.
Many times, we do not want duplicate rows or values in our SQL tables. On the other hand, in some situations, it does not matter if there are duplicates present. For whatever reason, suppose duplicates have found their way into one of your tables. How can you find them quickly and easily? The ROW_NUMBER()
Window function is a fantastic tool to use. Continue reading and see example queries you can apply to your own tables and find those duplicates…
Use MySQL BLOB column with PHP to store .pdf file
Like always I am sharing new things I learn here on my blog. I was recently working on a requirement for a LAMP stack web application reporting dashboard in which I needed to store – and eventually – retrieve a .pdf file. I have read in several places (this fantastic book is a great resource) that a viable option is storing images or documents (.pdf in this case) in the actual database table as opposed to on the server file system. MySQL has the BLOB
datatype that can be used to store files such as .pdf, .jpg, .txt, and the like. In this blog post, I cover how I accomplished uploading and storing the actual .pdf file in a BLOB
column in MySQL using PHP. Any corrections, tips, pointers, and recommendations for best practices are always welcome. We all learn as we go!!!
MySQL DROP statement using phpMyAdmin
The MySQL DROP
statement is one of many powerful DDL commands. Be it ALTER TABLE some_table DROP some_column
or DROP some_table
, this type of command can drastically change your data landscape because in executing MySQL DROP
, you are completely removing objects from the database! If you are using the phpMyAdmin web interface, you can execute the MySQL DROP
statement with just a few mouse clicks. Continue reading to see how…
MySQL Shell Python mode for multiple ALTER TABLE statements – easily
There may come a time you need to rename one or more columns in an existing MySQL table for a variety of reasons. Using ALTER TABLE
, to rename a column is an easy enough command. But, suppose there are multiple tables in the same database/schema that have the same-named column and all of those columns need to be renamed. That could be a lot of ALTER TABLE
statements to type out. Save your energy and time, avoiding all of those ALTER TABLE
commands all-together. If you are lucky enough to be working with a MySQL version > 8.0 then the Shell is your salvation. With just a few lines of Python code in \py
mode, all of your trouble(s) and headache(s) are no more…