Max Titov IV @ TechSplice

The most beautiful music of all is the music of what happens.
  • Home
  • About

Posts Tagged ‘sql’

6 May 2009

SQL: SELECT random number of rows

Here’s a quick way of requesting a random number of rows from a MySQL database:

SELECT * FROM <tablename> order by rand() limit <n>;

tablename: is the name of the table you wish to access

n: is thenumber of rows you wish to return

Be careful though, don’t use this logic on a database with a large record, the performance will be unpleasant.

6 May, 2009 at 12:17 by Max

Tags: database, random, select, sql
Posted in Everyday stuff | No Comments »

9 Dec 2007

Cyrilic integration of Flex and PHP

A recent project involved integration between a PHP content management tool like Joomla and Adobe Flex 2. I wrote a PHP script that parsed a MySQL database creating an XML structure that was then picked up by a HTTPService in a Flex application.

The information in the database was stored in Cyrillic format, hence when ever I was loading the data in to the SWF compiled file the end result was a collection of garbage data.  Setting the actuall HTML to Windows-1251 encoding did not help the situation.

My following approach was to locate a native functionality within the Flex architecture to mediate the situation.  Unforchunately I wasn’t successful in aquiring sattisfying examples to solve the problem.  For that matter it became sadly obvious that I haven’t seen any flash pages using non/english alphabet [either I haven't been checking international sites that much or Adobe Flex isn't widely used overseas] .

My third approach was to look at the actual php code that was generating the XML structure.  I’ve discovered a useful function mb_convert_encoding that eventually solved my problems.  Using a simple snippet of code:

mb_convert_encoding($string_to_convert,'UTF-8','Windows-1251');

I was able to convert the data from UTF-8 in to Windows-1251 which allowed me to display the desired Cyrillic characters.

9 December, 2007 at 19:57 by Max

Tags: code, development, flash, Flex, php, sql
Posted in Flex, Web Development | 2 Comments »

  • Subscribe using FeedBurner
  • Cloud

    abap adobe animation basic beautiful builder camera code configuration contribution design development digital engineering fix flash Flex friends function images interesting lesson new paypal Photography php problem problems program programmer review sap SAP/ABAP sdk setup soap software solution story system tables transaction transports user video

    WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.

  • My Links

    • Cooking
    • Gallery
    • Resume
  • Online Tools

    • Airline Ticket Search
    • Estimate Shipping Cost [from US]
    • Link your Blog
  • Software Engineering Blogs

    • Adam Goucher
    • Joel on Software
    • The Third Bit
    • Wide Awake Developers
  • Categories

    • Everyday stuff
    • Flex
    • Photography
    • SAP/ABAP
    • Short Stories
    • Software Engineering
    • Web Development
  • Gallery

    Roy Tanck's Flickr Widget requires Flash Player 9 or better.

Max Titov IV @ TechSplice is proudly powered by WordPress
Design & code by Jonk
Entries (RSS) and Comments (RSS).
Podcast Powered by podPress (v8.8)