Showing entries 41 to 50 of 233
« 10 Newer Entries | 10 Older Entries »
Displaying posts with tag: code (reset)
PHP MySQL BLOB PDF: Display in Browser

In Use MySQL BLOB column with PHP to store .pdf file, I covered an example of how to store a .pdf file in the actual database table using the MySQL BLOB datatype and PHP. Now that we have .pdf’s stored in the database, how do we display them in the browser? This blog post answers that exact question. Continue reading to see a working example using PHP…

Photo by Ben on Unsplash

Self-Promotion:

If you …

[Read more]
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!!!

Photo by …

[Read more]
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…

Photo by Ibrahim Rifath on …

[Read more]
MySQL EXTRACT() method for specific DATE and TIME values

Date and time values are some of the most important datatypes in an RDBMS. From tracking order dates to payroll hours, DATE and DATETIME datatypes are used in all types of applications. At times as a Developer, you may need only certain portions of a DATE or DATETIME value. In MySQL, the EXTRACT() function can provide you with a specific component of a DATE or DATETIME value depending on which INTERVAL is given as a parameter. Continue reading to see example EXTRACT() queries for understanding…

Photo by Omar Al-Ghossen on Unsplash

[Read more]
Dynamic MySQL CREATE TABLE statement with pandas and pyodbc

Have you ever had to type out a massive CREATE TABLE statement by hand? One with dozens of columns? Maybe several dozens of columns? There are likely some GUI tools to help with large CREATE TABLE commands. Or, other drag-n-drop types of software that I am not familiar with. What if you could write a few lines of Python code and take care of a huge CREATE TABLE statement with way less effort than typed manually? Interested? Continue reading and see how using pandas, pyodbc, and MySQL…

Photo by Vorsen Furniture on Unsplash

OS, Software, and DB used:

  • OpenSuse Leap 15.1
[Read more]
3 MySQL Commands Developers should know.

If you are a developer working in a MySQL environment, this blog post is for you. I share 3 MySQL commands or statements that you should know. That is a bold statement, I know. Turns out, once you do know (of) these commands, you will use them all the time. They minimize guesswork which leads to better productivity in other facets of your programming and querying workflow. I use them myself almost daily and am sure you will too once you see how simple they are to use. So why should you know them? Continue reading and find out…

Photo by hannah joshua on Unsplash

OS, Software, and DB used:

  • OpenSuse Leap 15.1
[Read more]
TRIM() string function in MySQL – with examples.

In this post, I’ll cover examples of the MySQL TRIM() function. TRIM() removes specific characters – or spaces – from a given string, at either: the beginning, ending, or potentially in both locations depending on several factors. With an optional keyword argument that controls which character(s) – if any – are removed, TRIM() can be tricky so let’s gain understanding with several easy-to-digest examples…

Photo by Peter Beukema on Unsplash

OS, Software, and DB used:

  • OpenSuse Leap 15.1
  • MySQL 8.0.20

Self-Promotion:

If you enjoy …

[Read more]
Sorting associative arrays in PHP with array_multisort() – New learning

If you write MySQL queries, at some point you are going to have to provide query results in a specific order. To impose any ordering in MySQL (this applies to SQL overall and is not directed only at MySQL), you have to use the ORDER BY clause. Without it, there is no guaranteed order. The database is free to send back query results in any order. As I learn PHP, I make it a point to explore both the MySQL side, along with the PHP side in regards to similar type tasks and the efficiency of each. So far in my PHP journey, I have found that arrays are used quite extensively. In this post, I’ll cover array_multisort() – one of many in-built PHP functions – used for sorting arrays. In the context of the example data for this post, the arrays are populated by an unordered MySQL query. Let’s see one example of how you can establish a sorting order in a PHP …

[Read more]
On Contributions, Pride and Cockiness

At MariaDB Foundation, we are proud of MariaDB Server getting plenty of contributions. But we don’t want to get cocky, so here is an update about where we stand, and what we want to make happen. First, we have shown our contribution pride in several places. On 15 February 2019, I tweeted On code contributions, […]

The post On Contributions, Pride and Cockiness appeared first on MariaDB.org.

How We Partitioned Airbnb’s Main Database in Two Weeks

“Scaling = replacing all components of a car while driving it at 100mph”

– Mike Krieger, Instagram Co-founder @ Airbnb OpenAir 2015

Airbnb peak traffic grows at a rate of 3.5x per year, with a seasonal summer peak.

Heading into the 2015 summer travel season, the infrastructure team at Airbnb was hard at work scaling our databases to handle the expected record summer traffic. One particularly impactful project aimed to partition certain tables by application function onto their own database, which typically would require a significant engineering investment in the form of application layer changes, data migration, and robust testing to guarantee data consistency with minimal downtime. In an attempt to save weeks of …

[Read more]
Showing entries 41 to 50 of 233
« 10 Newer Entries | 10 Older Entries »