New php API of MT5

| No Comments | No TrackBacks

Junnama Noda, president of Alfasado Inc., wrote an entry about a MT5’s New php API.

In this entry, he wrote some sample codes to use MT’s new API for php.

I think it is very useful for MT' developers, so I try to translate and introduce them.

Please let me know if there are the wrong points in my English usage.

*Loading an entry data

$args['class'] = 'entry'; $args['blog_id'] = $blog_id; $args['offset']=n; $args['limit']=n; $entries = $ctx->mt->db()->fetch_entries($args);

*Loading an entry or other object data via sql, with range specification

$entries = $ctx->mt->db()->SelectLimit( $sql, $limit, $offset );

*Executing sql

$entries = $ctx->mt->db()->Execute( $sql );

*Getting a number of object data

$entries->RecordCount();

*Loading each records

$entries->Move($counter); $entry = $entries->FetchRow();

*Definiting an entry data as an object

(attention: you need to coordinate definition of category, custom fields, and other MT’s data  in the sql settings)

$e; while(list ($key, $val) = each($entry)) { if (preg_match('/^entry_/',$key)) { $e->$key = $val; } } # $ctx->stash('entry', $e);

*Loading an object from an arbitrary entry data

$e = $ctx->mt->db()->fetch_entry($id)

*Loading an object from a web page data

$e = $ctx->mt->db()->fetch_page($id);

*Loading an object with “Find” method

require_once 'class.mt_entry.php'; #entry $_entry = new Entry; $where = $where_statment; $extra = array( 'limit' => $limit, 'offset' => $offset, ); $results = $_entry->Find($where, false, false, $extra);

No TrackBacks

TrackBack URL: http://www.mt-j.info/mt/mt-tb.cgi/72

Leave a comment

About this Entry

This page contains a single entry by nick published on March 9, 2010 10:00 PM.

Concealing your server information from “mt-check.cgi” was the previous entry in this blog.

Creating an entry list from plural blogs, under the same category is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.