26 Jun 2009 @ 4:01 AM 








many posts on the web page or blog. cause the page too long.  because of that, content on the web need pagination.follow the tutorial for creating pagination:

on cake php pagination created with class component and class element.

Component:

place component on directotry /app/controller/component/pagination.php

Element:

place component on directotry /app/views/elements/pagination.thtml

helpers :

place component on directotry /app/views/helpers/pagination.php

if that file placed on the each directory. that class must be call from controller . this is a example call the class pagination on controller :

<?php

class PagesController extends AppController {

var $uses = array(‘Data’);
var $helpers = array(‘Html’,'Pagination’,'Javascript’,'Ajax’);
var $components = array(‘Paginations’);
var $paging;

$criteria=”";
list($order,$limit,$page) = $this->Paginations->init($criteria);
$result=$this->Data->findAll(null,null,null,$limit,$page);

$this->set(‘data’,$result);

?>

to download full code and real example, you can download script on this link DOWNLOAD



Tags Tags: , , , , , , , ,
Categories: CakePHP
Posted By: asbin
Last Edit: 26 Jun 2009 @ 04 01 AM

EmailPermalinkComments (0)
 17 Jun 2009 @ 3:12 AM 

reduction date with mktime function

reduction date different with reduction number. the amount of time on php calculated on seconds unit.  because of that, to get the day time must be divided by seconds unit. 1 day have 86400 seconds, to get day time must be devided 86400.
following example :
(17-june-2009) – (1-mei-2009)    ….?

<?
$day=(mktime (0,0,0,6,17,2009) – mktime (0,0,0,5,1,2009))/86400;
$day=floor($day);
echo $day;
?>

result:  47 day.
result is 47. because between (17-june-2009) and (1-mei-2009) have 47 days.  this script is very simple but sometimes we need it to create a complicated algoritm.
Tags Tags:
Categories: php
Posted By: asbin
Last Edit: 17 Jun 2009 @ 03 12 AM

EmailPermalinkComments (0)
 16 Jun 2009 @ 11:37 PM 

Your app/config/database.php file is where your database configuration all takes place. A fresh install doesn’t have a database.php, so you’ll need to make a copy of database.php.default. Once you’ve made a copy and renamed it you’ll see the following:

Example 4.1. app/config/database.php

var $default = array('driver'   => 'mysql',
                     'connect'  => 'mysql_connect',
                     'host'     => 'localhost',
                     'login'    => 'user',
                     'password' => 'password',
                     'database' => 'project_name',
                     'prefix'   => '');


Replace the information provided by default with the database connection information for your application.

One note about the prefix key: the string you enter there will be prepended to any SQL call that Cake makes to your database when working with tables. You define it here once so you don’t have to specify it in other places. It also allows you to follow Cake’s table naming conventions if you’re on a host that only gives you a single database. Note: for HABTM join tables, you only add the prefix once: prefix_apples_bananas, not prefix_apples_prefix_bananas.

CakePHP supports the following database drivers:

  • mysql
  • postgres
  • sqlite
  • pear-drivername (so you might enter pear-mysql, for example)
  • adodb-drivername

The ‘connect’ key in the $default connection allows you to specify whether or not the database connection will be treated as persistent or not. Read the comments in the database.php.default file for help on specifying connection types for your database setup.

Your database tables should also follow the following conventions:

  • Table names used by Cake should consist of English words in plural, like “users”, “authors” or “articles”. Note that corresponding models have singular names.
  • Your tables must have a primary key named ‘id’.
  • If you plan to relate tables, use foreign keys that look like: ‘article_id’. The table name is singular, followed by an underscore, followed by ‘id’.
  • If you include a ‘created’ and/or ‘modified’ column in your table, Cake will automatically populate the field when appropriate.

You’ll also notice that there is a $test connection setting included in the database.php file. Fill out this configuration (or add other similarly formatted configurations) and use it in your application by placing something like:

var $useDbConfig = 'test';

Inside one of your models. You can add any number of additional connection settings in this manner.

Tags Tags: , ,
Categories: Configuration
Posted By: asbin
Last Edit: 22 Jun 2009 @ 11 46 PM

EmailPermalinkComments (0)
 16 Jun 2009 @ 11:10 PM 

In order use CakePHP you must first have a server that has all the required libraries and programs to run CakePHP:

Server Requirements

Here are the requirements for setting up a server to run CakePHP:

  1. An HTTP server (like Apache) with the following enabled: sessions, mod_rewrite (not absolutely necessary but preferred)
  2. PHP 4.3.2 or greater. Yes, CakePHP works great in either PHP 4 or 5.
  3. A database engine (right now, there is support for MySQL, PostgreSQL and a wrapper for ADODB).

Getting the most recent stable version

There are a few ways you can secure a copy of CakePHP: getting a stable release from CakeForge, grabbing a nightly build, or getting a fresh version of code from SVN.

To download a stable version of code, check out the files section of the CakePHP project at CakeForge by going to http://cakeforge.org/projects/cakephp/.

To grab a nightly, download one from http://cakephp.org/downloads/index/nightly. These nightly releases are stable, and often include the bug fixes between stable releases.

To grab a fresh copy from our SVN repository, use your favorite SVN client and connect to https://svn.cakephp.org/repo/trunk/cake/ and choose the version you’re after.

Unpacking

Now that you’ve downloaded the most recent release, place that compressed package on your web server in the webroot. Now you need to unpack the CakePHP package. There are two ways to do this, using a development setup, which allows you to easily view many CakePHP applications under a single domain, or using the production setup, which allows for a single CakePHP application on the domain.

Configuring Apache and mod_rewrite

Configuring Apache and mod_rewrite

While CakePHP is built to work with mod_rewrite out of the box, we’ve noticed that a few users struggle with getting everything to play nicely on their systems. Here are a few things you might try to get it running correctly:

  • Make sure that an .htaccess override is allowed: in your httpd.conf, you should have a section that defines a section for each Directory on your server. Make sure the AllowOverride is set to All for the correct Directory.
  • Make sure you are editing the system httpd.conf rather than a user- or site-specific httpd.conf.
  • For some reason or another, you might have obtained a copy of CakePHP without the needed .htaccess files. This sometimes happens because some operating systems treat files that start with ‘.’ as hidden, and don’t copy them. Make sure your copy of CakePHP is from the downloads section of the site or our SVN repository.
  • Make sure you are loading up mod_rewrite correctly! You should see something like LoadModule rewrite_module libexec/httpd/mod_rewrite.so and AddModule mod_rewrite.c in your httpd.conf.
  • If you are installing Cake into a user directory (http://example.com/~myusername/), you’ll need to modify the .htaccess file in the base directory of your Cake installation. Just add the line “RewriteBase /~myusername/“.
  • If for some reason your URLS are suffixed with a long, annoying session ID (http://example.com/posts/?CAKEPHP=4kgj577sgabvnmhjgkdiuy1956if6ska), you might also add “php_flag session.trans_id off” to the .htaccess file at the root of your installation as well.

Make Sure It’s Working

Make Sure It’s Working

Alright, lets see this baby in action. Depending on which setup you used, you should point your browser to http://www.example.com or http://www.example.com/cake. At this point, you’ll be presented with CakePHP’s default home, and a message that tells you the status of your current database connection.

Congratulations! You are ready to create your first Cake-based application.

Tags Tags: , ,
Categories: Installing CakePHP
Posted By: asbin
Last Edit: 17 Jun 2009 @ 03 51 AM

EmailPermalinkComments (0)
 11 Jun 2009 @ 11:51 PM 

sometimes we need to read a file for the program. now I can discuss about that.  php have default function to read the file on directory.

Example 1. dir() example

Please note the fashion in which dir()‘s return value is checked in the example below. We are explicitly testing whether the return value is identical to (equal to and of the same type as–see Comparison Operators for more information) FALSE since otherwise, any directory entry whose name evaluates to FALSE will stop the loop.

<?php
$d
= dir("/etc/php5");
echo
"Handle: " . $d->handle . "\n";
echo
"Path: " . $d->path . "\n";
while (
false !== ($entry = $d->read())) {
echo
$entry."\n";
}
$d->close();
?>

The above example will output something similar to:

Handle: Resource id #2
Path: /etc/php5
.
..
apache
cgi
cli

hope that helps….

Tags Tags: , , ,
Categories: mhh
Posted By: asbin
Last Edit: 11 Jun 2009 @ 11 51 PM

EmailPermalinkComments (0)
 11 Jun 2009 @ 5:37 AM 

The Extensible Markup Language (XML) is a markup language much like HTML or SGML. This is recommended by the World Wide Web Consortium and available as an open standard.

XML is a portable, open source language that allows programmers to develop applications that can be read by other applications, regardless of operating system and/or developmental language.

now I will talk about reading xml with php. php can read the xml script with the following code :
index.php
<?php
$xml = “”;
$f = fopen( ‘books.xml’, ‘r’ );
while( $data = fread( $f, 4096 ) ) {
$xml .= $data;
}
fclose( $f );

preg_match_all( “/\<Envelope\>(.*?)\<\/Envelope\>/s”,
$xml, $bookblocks );

foreach( $bookblocks[1] as $block )
{
preg_match_all( “/\<Filename\>(.*?)\<\/Filename\>/”,
$block, $author );
preg_match_all( “/\<MessageType\>(.*?)\<\/MessageType\>/”,
$block, $title );
preg_match_all( “/\<Owner\>(.*?)\<\/Owner\>/”,
$block, $publisher );
echo( $title[1][0].” – “.$author[1][0].” – “.
$publisher[1][0].”\n” );
}

?>

books.xml
<Envelope>
<Filename>CRQQGZNT.xml</Filename>
<MessageType>SMS:TEXT</MessageType>
<Owner>admin</Owner>
</Envelope>
because xml not server side script . xml can be read  by php to process in the server side.  script can be downloaded here
Tags Tags: , , , , , ,
Categories: php
Posted By: asbin
Last Edit: 11 Jun 2009 @ 05 37 AM

EmailPermalinkComments (2)
 09 Jun 2009 @ 8:23 AM 

Routes Configuration

Routes Configuration

“Routing” is a pared-down pure-PHP mod_rewrite-alike that can map URLs to controller/action/params and back. It was added to Cake to make pretty URLs more configurable and to divorce us from the mod_rewrite requirement. Using mod_rewrite, however, will make your address bar look much more tidy.

Routes are individual rules that map matching URLs to specific controllers and actions. Routes are configured in the app/config/routes.php file. They are set-up like this:

Example 4.2. Route Pattern

<?php
$Route->connect (
    'URL',
    array('controller'=>'controllername',
    'action'=>'actionname', 'firstparam')
);
?>


Where:

  • URL is the regular expression Cake URL you wish to map,
  • controllername is the name of the controller you wish to invoke,
  • actionname is the name of the controller’s action you wish to invoke,
  • and firstparam is the value of the first parameter of the action you’ve specified.

Any parameters following firstparam will also be passed as parameters to the controller action.

The following example joins all the urls in /blog to the BlogController. The default action will be BlogController::index().

Example 4.3. Route Example

<?php
$Route->connect ('/blog/:action/*', array('controller'=>'Blog', 'action'=>'index'));
?>


A URL like /blog/history/05/june can then be handled like this:

Example 4.4. Route Handling in a Controller

<?php
class BlogController extends AppController
{
 function history ($year, $month=null)
 {
   // .. Display appropriate content
 }
}
?>


The ‘history’ from the URL was matched by :action from the Blog’s route. URL elements matched by * are passed to the active controller’s handling method as parameters, hence the $year and $month. Called with URL /blog/history/05, history() would only be passed one parameter, 05.

The following example is a default CakePHP route used to set up a route for PagesController::display(‘home’). Home is a view which can be overridden by creating the file /app/views/pages/home.thtml.

Example 4.5. Setting the Default Route

<?php
$Route->connect ('/', array('controller'=>'Pages', 'action'=>'display', 'home'));
?>

resource: manual cakephp download

Tags Tags: , , , , , , , ,
Categories: mhh
Posted By: asbin
Last Edit: 09 Jun 2009 @ 08 28 AM

EmailPermalinkComments (0)
 09 Jun 2009 @ 8:18 AM 

Database Configuration

Your app/config/database.php file is where your database configuration all takes place. A fresh install doesn’t have a database.php, so you’ll need to make a copy of database.php.default. Once you’ve made a copy and renamed it you’ll see the following:

Example 4.1. app/config/database.php

var $default = array('driver'   => 'mysql',
                     'connect'  => 'mysql_connect',
                     'host'     => 'localhost',
                     'login'    => 'user',
                     'password' => 'password',
                     'database' => 'project_name',
                     'prefix'   => '');


Replace the information provided by default with the database connection information for your application.

One note about the prefix key: the string you enter there will be prepended to any SQL call that Cake makes to your database when working with tables. You define it here once so you don’t have to specify it in other places. It also allows you to follow Cake’s table naming conventions if you’re on a host that only gives you a single database. Note: for HABTM join tables, you only add the prefix once: prefix_apples_bananas, not prefix_apples_prefix_bananas.

CakePHP supports the following database drivers:

  • mysql
  • postgres
  • sqlite
  • pear-drivername (so you might enter pear-mysql, for example)
  • adodb-drivername

The ‘connect’ key in the $default connection allows you to specify whether or not the database connection will be treated as persistent or not. Read the comments in the database.php.default file for help on specifying connection types for your database setup.

Your database tables should also follow the following conventions:

  • Table names used by Cake should consist of English words in plural, like “users”, “authors” or “articles”. Note that corresponding models have singular names.
  • Your tables must have a primary key named ‘id’.
  • If you plan to relate tables, use foreign keys that look like: ‘article_id’. The table name is singular, followed by an underscore, followed by ‘id’.
  • If you include a ‘created’ and/or ‘modified’ column in your table, Cake will automatically populate the field when appropriate.

You’ll also notice that there is a $test connection setting included in the database.php file. Fill out this configuration (or add other similarly formatted configurations) and use it in your application by placing something like:

var $useDbConfig = 'test';

Inside one of your models. You can add any number of additional connection settings in this manner.

Tags Tags: , , , , , , ,
Categories: mhh
Posted By: asbin
Last Edit: 09 Jun 2009 @ 08 18 AM

EmailPermalinkComments (0)
 08 Jun 2009 @ 11:16 AM 

This AJAX method periodically performs an AJAX request and updates a container’s contents based on the response text.

Containers are specified by giving IDs of the HTML elements like division or paragraphs. See example below.

Callbacks are called at various points in the life-cycle of a request, and always feature the same list of arguments. They are passed to requesters right along with their other options.
Syntax:

new Ajax.PeriodicalUpdater(container, url[, options]);

Ajax.PeriodicalUpdater features all the Common Options and callbacks, plus those added by Ajax.Updater().

There are two more options specific to this method:
Option Description
frequency Default value is 2.
This is the minimum interval at which AJAX requests are made.
decay Default value is 1.
This controls the rate at which the request interval grows when the response is unchanged.
Return Value :

* Returns AJAX PeriodicalUpdater object.

Disabling and Enabling a PeriodicalUpdater :

You can pull the brake on a running PeriodicalUpdater by simply calling its stop method. If you wish to re-enable it later, just call its start method. Both take no argument.
Example:


Click start button to see how Current Time changes.

This example may not work in IE.

Current Time

Here is the content of timer.cgi script:

#!/usr/bin/perl

print “Content-type: text/html\n\n”;

$datetime = localtime;
print $datetime;
print ”
“;

www.tutorialspont.com

Tags Tags: , , , , , , , , ,
Categories: ajax
Posted By: asbin
Last Edit: 08 Jun 2009 @ 11 28 AM

EmailPermalinkComments (0)
 04 Jun 2009 @ 12:58 AM 

multiple uplaod file dengan cakephp

multi file upload dengan cakephp. multi upload digunakan untuk meng upload beberapa file secara bersamaan.  untuk download script silahkan klik di sini untuk DOWNLOAD

Tags Tags:
Categories: CakePHP
Posted By: asbin
Last Edit: 04 Jun 2009 @ 12 58 AM

EmailPermalinkComments (0)
\/ More Options ...
Change Theme...
  • Users » 1
  • Posts/Pages » 49
  • Comments » 50
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.