My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
API  

Featured
Updated Sep 23, 2008 by rawsw...@gmail.com

These are the list of methods that are available for developers. This document serve as a reference for developers building application using Orinoco Framework.

Application Methods

render_content

boolean render_content ( void )

Description:

Render action’s view template. This method is called inside the layout template.

Parameters:

void

Return Values:

boolean true if successful, otherwise false.

Example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
	<?php
		$this->render_content();
	?>
</body>
</html>

render_partial

boolean render_partial ( string $partial_name )

Description:

Render partial template.

Parameters:

string $partial_name partial template name

Return Values:

boolean true if successful, otherwise false.

Example:

<div>
    <?php
        $this->render_partial('left_panel');
    ?>
</div>

redirect_to

void redirect_to ( string $action = NULL, string $controller = NULL, string $additional_parameters = NULL, string $time_interval = 0 )

Description:

Redirect page then terminate current request.

Parameters:

string $action action/page where to redirect

string $controller controller/page to redirect
array $additional_parameters additional parameters, e.g. ?id=1&name=foo&add=bar
int $time_interval time/seconds before redirect

Return Values:

void

Example:

class usersController extends Controller {
	function __index__() {
		$this->users->find();
	}

	function edit() {
		$this->users->select($this->_id);
	}
	
	function update() {
		if(isset($this->_post)) {
			$this->users->select($this->_id);
			$this->users->update($this->_post);
			$this->redirect_to();		
		}
	}
	
	function delete() {
		$this->users->delete($this->_id);
		$this->redirect_to();
	}
	
}

use_template

boolean use_template ( string $action, string $controller = NULL )

Description:

Explicitly use other view file instead of its associated view template.

Parameters:

string $action view/action template to use

string $controller view/controller template to use

Return Values:

boolean true if file exist else throw an exception.

Example:

class projectsController extends Controller {
	
	function __index__() {
		$this->lists();
		$this->use_template('lists');
	}
	
	function lists() {
		$this->projects->find(array('order' => 'created_on DESC'));
	}

}

link_to

void link_to ( string $title = NULL, string $action = NULL, string $controller = NULL, string $additional_parameters = NULL )

Description:

Construct hyperlink/anchor text.

Parameters:

string $title link name

string $action action name
string $controller controller name
array $additional_parameters additional parameters, e.g. ?id=1&name=foo&add=bar

Return Values:

void

Example:

<div>
    <ul>
	<li><?php $this->link_to('Create a project', 'create'); ?></li>
        <li><?php $this->link_to('List all projects', 'lists'); ?></li>
    </ul>
</div>

to_word

string to_word ( string $permalink )

Description:

Convert permalink/URI format to word format.

Parameters:

string $permalink string to convert

Return Values:

string in word format

Example:

<div>
	<?php
		echo $this->to_word('this-should-be-in-human-readable-format');
	?>
</div>

to_permalink

string to_permalink ( string $string )

Description:

String to permalink format.

Parameters:

string $string string to convert.

Return Values:

string in permalink format.

Example:

<div>
	<?php
		echo $this->to_permalink('this should be an elegant url');
	?>
</div>

start_form_tag

void start_form_tag ( string $action, string $controller = NULL, string $method = NULL, string $additional_parameters = NULL )

Description:

Create HTML form tag.

Parameters:

string $action action name

string $controller controller name
string $method method type, get or post
array $additional_parameters additional parameters, e.g. ?id=1&name=foo&add=bar

Return Values:

void

Example:

<div>
	<?php $this->start_form_tag('create'); ?>
	<table>
		<tr><td>Name</td><td><?php $this->users->first_name->input_tag(); ?></td></tr>
		<tr><td>E-mail</td><td><?php $this->users->email_address->input_tag(); ?></td></tr>
		<tr><td>Position</td><td><?php $this->users->position_id->select_tag('position_name'); ?></td></tr>		
		<tr>
			<td colspan="2" align="right">
				<?php $this->button_tag('Create!'); ?>&nbsp;&nbsp;|&nbsp;&nbsp;
				<?php $this->link_to('Cancel'); ?>
			</td>
		</tr>
	</table>
	<?php $this->end_form_tag(); ?>
</div>

end_form_tag

void end_form_tag ( void )

Description:

Create HTML end from tag.

Parameters:

void

Return Values:

void

Example:

<div>
	<?php $this->start_form_tag('save'); ?>
		Name: <input id="info[email]" name="info[email]" value="" /><br />
		<input type="submit" value="Save!" />
	<?php $this->end_form_tag(); ?>
</div>

button_tag

void button_tag ( string $value = 'Submit', string $type = 'submit')

Description:

Create a button tag.

Parameters:

string $value button value/name

string $type button type

Return Values:

void

Example:

<div>
	<?php $this->start_form_tag('save'); ?>
		Name: <input id="info[email]" name="info[email]" value="" /><br />
		<?php $this->button_tag('Save!'); ?>
	<?php $this->end_form_tag(); ?>
</div>

debug_array

void debug_array ( array $arr )

Description:

Print/Display an array.

Parameters:

array $arr array to print/display

Return Values:

void

Example:

<div>
	<?php $this->debug_array($this); ?>
</div>

Post/Get Data Methods

set_value

void set_value ( $value )

Description:

Set object value.

Parameters:

mixed $value value

Return Values:

void

Example:

class usersController extends Controller {
	function __index__() {
		// do nothing
	}

	function create() {
		if(isset($this->_post)) {
	            // set password value as MD5 hash
    	        	$this->_post->users->password->set_value($this->_post->users->password->md5_hash());
        	    // save post data                
            		$this->users->save($this->_post);
	            // redirect to controller's index method
    	        	$this->redirect_to(); 
		}
	}
}

get_value

mixed get_value ( void )

Description:

Get objects current value.

Parameters:

void

Return Values:

mixed current value

Example:

<div>
	Email address: <?php echo $this->_post->email->get_value(); ?>
</div>

to_upper

string to_upper ( void )

Description:

Convert to uppercase.

Parameters:

void

Return Values:

string uppercased

Example:

<div>
	Name: <?php echo $this->_post->name->to_upper(); ?>
</div>

to_lower

string to_lower ( void )

Description:

Convert to lowercase.

Parameters:

void

Return Values:

string lowercased

Example:

<div>
	Name: <?php echo $this->_post->name->to_lower(); ?>
</div>

to_upper_first

string to_upper_first ( void )

Description:

Uppercase first char of string.

Parameters:

void

Return Values:

string uppercased first char

Example:

<div>
	Name: <?php echo $this->_post->name->to_upper_first(); ?>
</div>

to_upper_words

string to_upper_words ( void )

Description:

Uppercase first char of each word.

Parameters:

void

Return Values:

string uppercased first char of every words on string

Example:

<div>
	Name: <?php echo $this->_post->name->to_upper_first(); ?>
</div>

to_permalink

string to_permalink ( void )

Description:

Convert object value in its permalink form.

Parameters:

void

Return Values:

string permalink format

Example:

<div>
	<?php echo $this->_post->name->to_permalink(); ?>
</div>

md5_hash

string md5_hash ( string $salt = NULL)

Description:

Returns MD5 hash with salt option.

Parameters:

string $salt salt

Return Values:

string MD5 hash

Example:

<div>
	<?php echo $this->_post->password->md5_hash('salt123'); ?>
</div>

sha1_hash

string sha1_hash ( string $salt = NULL)

Description:

Returns SHA-1 hash with salt option.

Parameters:

string $salt salt

Return Values:

string SHA-1 hash

Example:

<div>
	<?php echo $this->_post->password->sha1_hash('salt123'); ?>
</div>

Object-relational Mapping

find

boolean find ( int|array $param = NULL, boolean $debug = false )

Description:

Find records w/ multiple table join support.

Parameters:

int|array $param accepts id or array {condition, order, limit} clause

boolean $debug set true if you want to see the generated SQL statement

Return Values:

boolean true if query is successful, otherwise false

Example:

class usersController extends Controller {
	function __index__() {
		$this->users->find(array('order' => 'created_on DESC'));
	}
}

select

boolean select ( int|array $param = NULL, boolean $debug = false )

Description:

Select record(s) for edit, update or delete.

Parameters:

int|array $param accepts id or array {condition, order, limit} clause

boolean $debug set true if you want to see the generated SQL statement

Return Values:

boolean true if query is successful, otherwise false

Example:

class usersController extends Controller {
	function __index__() {
		// do nothing
	}
    
	function edit() {
	    $this->users->select($this->_id);    
	}
    
	function update() {
		if(isset($this->_post)) {
			$this->users->select($this->_id);
			$this->users-save($this->_post);
			$this->redirect_to();
		}
	}
}

query

boolean query ( string $sql_statement )

Description:

Direct/raw SQL query.

Parameters:

string $sql_statement SQL statement

Return Values:

boolean true if query is successful, otherwise false

Example:

class usersController extends Controller {
	function __index__() {
		$this->users->query('SELECT * FROM users WHERE last_name = "foobar"');
	}
}

iterate

boolean iterate ( void )

Description:

Iterate through model's records.

Parameters:

void

Return Values:

boolean true if query is successful, otherwise false

Example:

<div>
	<table border="1" cellpadding="5" style="border-collapse:collapse;">
	<?php while($this->users->iterate()) { ?>
		<tr>
			<td><?php echo $this->users->id; ?></td>
			<td><?php echo $this->users->name->link_id_to('edit'); ?></td>
			<td><?php echo $this->users->email; ?></td>
			<td><?php echo $this->users->id->link_id_to('delete', 'Delete'); ?></td>
		</tr>
	<?php } ?>
	</table>
</div>

save

boolean save ( array $param = NULL, boolean $debug = false )

Description:

Save object or array on model.

Parameters:

object|array $param array or post object

boolean $debug set true if you want to see the generated SQL statement

Return Values:

boolean true if query is successful, otherwise false

Example:

class usersController extends Controller {
	function __index__() {
		// do nothing
	}

	function create() {
		if(isset($this->_post)) { // check of post has data
			$this->users->save($this->_post);
			$this->redirect_to(); // redirect to index action
		}
	}
}

update

boolean update ( int|array $param = NULL, boolean $debug = false )

Description:

Update model's record.

Parameters:

int|array $param accepts id or array {condition, order, limit} clause

boolean $debug set true if you want to see the generated SQL statement

Return Values:

boolean true if query is successful, otherwise false

Example:

class usersController extends Controller {
	function __index__() {
		// do nothing
	}
    
	function edit() {
		$this->users->select($this->_id);    
	}
    
	function update() {
		if(isset($this->_post)) { // check if post has date
			$this->users->select($this->_id); // select record to be updated
			$this->users->update($this->_post); // update record
			$this->redirect_to(); // redirect to index action
		}
	}  
}

delete

boolean delete ( int|array $param = NULL, boolean $debug = false )

Description:

Delete record from the model.

Parameters:

int|array $param accepts id or array {condition, order, limit} clause

boolean $debug set true if you want to see the generated SQL statement

Return Values:

boolean true if query is successful, otherwise false

Example:

class usersController extends Controller {
	function __index__() {
		// do nothing
	}

	function delete() {
		$this->users->delete($this->_id);
		$this->redirect_to();
	}    

}

record_count

boolean record_count ( void )

Description:

Returns model's row/record count.

Parameters:

void

Return Values:

boolean true if record found, otherwise false

Example:

<div>
	Model contains <?php echo $this->users->record_count(); ?> records.
</div>

ORM Data Helper

to_upper

string to_upper ( void )

Description:

Returns uppercased value.

Parameters:

void

Return Values:

string uppercased value

Example:

<div>
	Name: <?php echo $this->users->name->to_upper(); ?>
</div>

to_lower

string to_lower ( void )

Description:

Returns lowercased value/string.

Parameters:

void

Return Values:

string lowercased value

Example:

<div>
	Account Name: <?php echo $this->users->account_name->to_lower(); ?>
</div>

to_upper_first

string to_upper_first ( void )

Description:

Returns a value/string with the first charater in uppercase.

Parameters:

void

Return Values:

string uppercased value

Example:

<div>
	<textarea>
		<?php echo $this->blogs->content->to_upper_first(); ?>
	</textarea>
</div>

to_upper_words

string to_upper_words ( void )

Description:

Returns a value/string with all first character of words in uppercase.

Parameters:

void

Return Values:

string uppercased words

Example:

<div>
	<?php echo $this->blogs->title->to_upper_words(); ?>
</div>

to_permalink

string to_permalink ( void )

Description:

Returns current value to permalink or URI format.

Parameters:

void

Return Values:

string permalink format

Example:

<div>
	<a href="http://www.domain.tld/<?php echo $this->blogs->title->to_permalink(); ?>">Newest post</a>
</div>

md5_hash

string md5_hash ( string $salt = NULL )

Description:

Returns MD5 hash with salt option.

Parameters:

string $salt salt/string

Return Values:

string MD5 hash

Example:

	<?php echo $this->model->text->md5_hash('salt123'); ?>

sha1_hash

string sha1_hash ( string $salt = NULL )

Description:

Returns SHA-1 hash with salt option.

Parameters:

string $salt salt/string

Return Values:

string SHA-1 hash

Example:

	<?php echo $this->model->text->sha1_hash('salt123'); ?>

format_date

string format_date ( string $format = 'F d, Y' )

Description:

Returns formatted date.

Parameters:

string $format date format

Return Values:

string date format

Example:

	<?php echo $this->projects->created_on->format_date("M d"); ?>

format_timestamp

string format_timestamp ( string $format = 'F d, Y g:ia' )

Description:

Returns formatted timestamp.

Parameters:

string $format timestamp format

Return Values:

string date format

Example:

	<?php echo $this->projects->due_date->format_timestamp(); ?>

format_time

string format_time ( string $format = 'g:ia' )

Description:

Returns formatted time.

Parameters:

string $format time format

Return Values:

string time format

Example:

<div>
	<?php echo $this->projects->updated_on->format_time(); ?>
</div>

ORM Data Input Helper

input_tag

void input_tag ( array $array_attributes = NULL )

Description:

Create and print basic input tag.

Parameters:

array $array_attributes additional tag attributes

Return Values:

void

Example:

<div>
	<?php $this->users->name->input_tag(); ?>
</div>

textarea_tag

void textarea_tag ( array $array_attributes = NULL, string $init_text = NULL )

Description:

Create and print basic textarea tag.

Parameters:

array $array_attributes additional tag attributes

string $init_text initial text that will appear in textarea

Return Values:

void

Example:

<div>
	<?php $this->blogs->content->textarea_tag(); ?>
</div>

select_tag

void select_tag ( string $option = NULL, string $value = 'id', string|array $init_choice = NULL )

Description:

Create and print basic select tag.

Parameters:

string $option option resource

string $value value attribute to use; the default is 'id'
string|array $init_choice initial text choice or array

Return Values:

void

Example:

<div>
	<?php $this->blogs->category->select_tag(); ?>
</div>

link_id_to

void link_id_to ( string $action = NULL, string $title = NULL, string $controller = NULL, array $additional_parameters = NULL )

Description:

Construct a hyperlink which points to its record ID.

Parameters:

string $action action name

string $title link name
string $controller controller name
array $additional_parameters additional parameters, e.g. ?id=1&name=foo&add=bar

Return Values:

void

Example:

<div>
	<?php echo $this->projects->project_name->link_id_to('show'); ?>
</div>
Comment by manhgd....@gmail.com, Apr 27, 2009

Thank your work! I found your project simple make power!


Sign in to add a comment
Powered by Google Project Hosting