This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 16.9, “A quick look at the Slick database library.”
Here’s a cool tip: if you want to search for a text string in all fields of all tables of a MySQL database, you can use phpMyAdmin to do this very easily. Here are the steps to search every MySQL database table.
1) Select the desired database
The first step is to select the database you want to search. Don’t select a table — just select the database you want to search. (If you select a table you’ll get a different search form in Step 2.)
I’m not going to comment on the following code too much or provide support for it, but (a) if you need to create an XML Sitemap for a Drupal 8 website, and (b) you don’t like the Drupal 8 sitemap modules that are available, then (c) this PHP script can serve as a starting point for you.
If you want to list all of the MySQL database table column names (field names) as a simple list of names, with each column name listed on a separate line, just follow these steps.
First, start MySQL with the
-sN options, like this:
$ mysql -sN -u root -p
Then execute a query like this:
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 16.3, “How to connect to a MongoDB and insert data with Scala.”
You want to use the MongoDB database with a Scala application, and want to learn how to connect to it, and insert and retrieve data.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 16.2, “How to connect to a database with the Spring Framework.”
You want to connect to a database using the Spring Framework. This gives you a nice way to add connection pooling and other capabilities to your SQL code.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 16.1, “How to connect to a MySQL database with Scala and JDBC.”
You want to connect to a MySQL database (or any other database with a JDBC driver) from a Scala application using “plain old JDBC.”
Use JDBC just like you would in a Java application. Download the MySQL JDBC driver, and then access your database with code like this:
Here are a few short examples of how to find an object in a Sencha Store (ExtJS or Sencha Touch).
As a first example, imagine that you have a Store of users, and want to find a user with the first name of “Alvin”. Assuming that your user model has a field named
firstName, your query would look like this:
var user = usersStore.findRecord('firstName', 'Alvin');
After this query you can use the
user object just as though you had created it by hand. (The object returned is a
To create an order by query using the
find method of the MongoDB Casbah driver (Scala), use the
sort method, as shown in this example:
While developing a Drupal module, I just ran into a situation where it may be common for users to generate SQL exceptions. I have a 'unique' limit on several of my database tables, essentially saying that certain name fields must be unique for the current project. As you can imagine, it's extremely easy to enter a duplicate name, and while doing a SQL INSERT that can easily lead to a SQL exception.
As a result, I dug around and found a way to handle SQL exceptions in Drupal queries. My current problem is with a Drupal 7 db_insert query, and I handled it like this: