‘Mysql’ Archive

Wordpress change rss channel language

I got a problem with http://rapid-dev.net/feed/ language. When I viewed source of the feed it said that no language specified:

...
	<title>rapid-DEV.net</title>
	<atom:link href="http://rapid-dev.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://rapid-dev.net</link>
	<description>Accumulate and share your experience</description>
	<lastBuildDate>Mon, 09 Nov 2009 11:09:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language></language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
...

Then I tried to check wordpress /wp-includes/feed-rss2.php source file to see what was happening:

...
	<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
	<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
	<link><?php bloginfo_rss('url') ?></link>
	<description><?php bloginfo_rss("description") ?></description>
	<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
	<?php the_generator( 'rss2' ); ?>
	<language><?php echo get_option('rss_language'); ?></language>
	<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
	<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
	<?php do_action('rss2_head'); ?>
	<?php while( have_posts()) : the_post(); ?>
	<item>
...

After that, I search in Wordpress Option table to found out what’s value of option_name rss_language by using this sql query:

SELECT * FROM `_options` WHERE `option_name` = 'rss_language'

MySQL returned an empty result set ( 0 row found ).

Finally, I decided to insert one new record with `option_name` = ‘rss_language’ and `option_value` = ‘en’ to my wordpress option table:

INSERT INTO `_options` (`option_id`, `blog_id`, `option_name`, `option_value`, `autoload`) VALUES (NULL, '0', 'rss_language', 'en', 'yes');

Close all browser and try to make some change to make sure caches or global options are refreshed.

Please take note that autoload is yes to make sure it will be load automaticly.

And … and … and … it worked correctly.

Hope it will solve your problem!

mysql backup table using SELECT INTO OUTFILE and restore using LOAD DATA INFILE

Using SELECT INTO OUTFILE query to create table backup:

SELECT * INTO OUTFILE 'C:/nsw_members.sql' FROM nsw_members

Using LOAD DATA INFILE to restore the backup

LOAD DATA INFILE 'C:/nsw_members.sql' INTO TABLE nsw_members

Don’t forget to change location & table name correspond to your enviroment.

Options for Using MySQL with PHP

PHP currently offers multiple ways of working with MySQL. Some of the more popular methods include:

PEAR (PHP Extension and Apppcation Repository) DB package

This package offers a database-independent API for communicating with relational databases from PHP. PEAR::DB includes support for MySQL, but provides only rudimentary support for MySQL stored programs.

PHP MySQL extension (ext/mysql)

This PHP extension provides MySQL-specific support for working with MySQL. However, the mysql extension does not include methods for working with advanced MySQL features introduced in MySQL 4.1 and 5.0 and will probably never provide direct support for stored programs.

mysqp interface (ext/mysqp)

This PHP extension was introduced to support new features in MySQL 4.1 and 5.0.

PDO (PHP Data Objects)

PDO is a database-independent interface that will probably become the successor to the PEAR::DB interface. PDO became an officially supported interface only in PHP 5.1, so it is the newest of the PHP database interfaces.

Only the mysqp and PDO extensions provide full support for MySQL stored programs.

Why Use Stored Programs

Developers have a multitude of programming languages from which to choose. Many of these are not database languages, which means that the code written in these languages does not reside in, nor is it managed by, a database server. Stored programs offer some very important advantages over more general-purpose languages, including:

  • The use of stored programs can lead to a more secure database.

  • Stored programs offer a mechanism to abstract data access routines, which can improve the maintainability of your code as underlying data structures evolve.

  • Stored programs can reduce network traffic, because the program can work on the data from within the server, rather than having to transfer the data across the network.

  • Stored programs can be used to implement common routines accessible from multiple applicationspossibly using otherwise incompatible frameworks executed either within or from outside the database server.

  • Database-centric logic can be isolated in stored programs and implemented by programmers with more specialized, database experience.

  • The use of stored programs can, under some circumstances, improve the portability of your application.

While this is an impressive list of advantages, we do not recommend that you immediately move all your application logic into stored programs. In today’s rich and complex world of software technology, you need to understand the strengths and weaknesses of each possible element in your software configuration, and figure out how to maximize each element.

Mysql Northwind database

Database similiar to MSSQL Northwind

It’s a Mysql version of the Microsoft Sql Server Northwind database. It would be nice for newbies to start out with.

Here we go: mysql_northwind

Just create a new Mysql Database, use this command to import mysql_northwind.sql to your database:

mysql -u root -p -h localhost --default-character-set=utf8 northwind < mysql_northwind.sql