My favorites | Sign in
Project Logo
                
Search
for
Updated Nov 19, 2008 by ghalex
Labels: Featured
FlexDBTutorial  

Take a look at AS3FlexDB Tutorial 1 tutorial from iTutorials.ro

Simple example

All you need to load a table (for ex. "users") into a datagrid after you have install amfphp and set "services-config.xml" correctly is :

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
	layout="vertical"
	xmlns:phi="phi.db.*"
	xmlns:mx="http://www.adobe.com/2006/mxml">

	<mx:DataGrid
		id="dg1"
		width="100%"
		height="100%"
		dataProvider="{q1.Records}">
		<mx:columns>
			<mx:DataGridColumn dataField="fname" headerText="First Name"/>
			<mx:DataGridColumn dataField="lname" headerText="Last Name"/>
			<mx:DataGridColumn dataField="password" headerText="Password"/>
		</mx:columns>
	</mx:DataGrid>
	
	<phi:ConnectionData id="c1" name="mxml_conn1" host="localhost" db="test" username="root" password="root" />
	<phi:Database id="db1" connection="{c1}" />
	<phi:Query id="q1" database="{db1}" q="SELECT * FROM users WHERE 1" />
	<phi:QueryExecute id="q1ex" query="{q1}" />
</mx:Application>

Table structures is:

CREATE TABLE `users` (
  `id` int(5) NOT NULL auto_increment,
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `fname` varchar(255) NOT NULL,
  `lname` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

Comment by Hassan...@lesieur-cristal.co.ma, Apr 08, 2009

good

Comment by ngotancuonglongan, Jun 07, 2009

so cool. I just try it. very great!. thanks so much!!!!

Comment by ngotancuonglongan, Jun 07, 2009
<phi:ConnectionData? id="c1" name="mxml_conn1" host="localhost" db="test" username="root" password="root" />

when i change "localhost" to other word (ex: 'cuong'), it not work. althought i create Privilages (ex: 'cuong' full control) in Mysql

please help me! thanks.

Comment by wmkmws, Jul 03, 2009

i have the problem above too. please help!

Comment by jasonvillmer, Aug 18, 2009

Running Flex 3. As soon as the example runs, I get this:

Error: A connection with the same name exist!

at phi.db::Database/connect()Flex\FlexDB\src\phi\db\Database.as:103? at phi.db::Database/set connection()Flex\FlexDB\src\phi\db\Database.as:109? at mx.binding::Binding/defaultDestFunc()E:\dev\beta1\frameworks\projects\framework\src\mx\binding\Binding.as:262? at Function/http://adobe.com/AS3/2006/builtin::call() at mx.binding::Binding/innerExecute()E:\dev\beta1\frameworks\projects\framework\src\mx\binding\Binding.as:458? at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.binding::Binding/wrapFunctionCall()E:\dev\beta1\frameworks\projects\framework\src\mx\binding\Binding.as:370? at mx.binding::Binding/execute()E:\dev\beta1\frameworks\projects\framework\src\mx\binding\Binding.as:306? at FlexDBExample()Builder 3/FlexDBExample/src/FlexDBExample.mxml:5? at FlexDBExample_mx_managers_SystemManager?/create() at mx.managers::SystemManager?/initializeTopLevelWindow()E:\dev\beta1\frameworks\projects\framework\src\mx\managers\SystemManager.as:3581? at mx.managers::SystemManager?/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()[E:\dev\beta1\frameworks\projects\framework\src\mx\managers\SystemManager.as:3400] at mx.managers::SystemManager?/docFrameListener()E:\dev\beta1\frameworks\projects\framework\src\mx\managers\SystemManager.as:3258?


Sign in to add a comment
Hosted by Google Code