Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
d914517f
Commit
d914517f
authored
Feb 27, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first import docs
parent
c8663663
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
Getting started - Working with existing databases - Making the first import.php
...ing with existing databases - Making the first import.php
+55
-0
No files found.
manual/docs/Getting started - Working with existing databases - Making the first import.php
0 → 100644
View file @
d914517f
Let
's consider we have a mysql database called test with a single table called '
file
'.
The file table has been created with the following sql statement:
CREATE TABLE file (
id INT AUTO_INCREMENT NOT NULL,
name VARCHAR(150),
size BIGINT,
modified BIGINT,
type VARCHAR(10),
content TEXT,
path TEXT,
PRIMARY KEY(id))
Now we would like to convert it into Doctrine record class. It can be achieved easily with the following code snippet:
<code type='
php
'>
require_once('
lib
/
Doctrine
.
php
');
spl_autoload_register(array('
Doctrine
', '
autoload
'));
$conn = Doctrine_Manager::connection(new Doctrine_Db('
mysql
://
root
:
dc34
@
localhost
/
test
'));
// import method takes one parameter: the import directory (the directory where
// the generated record files will be put in
$conn->import->import('
myrecords
');
</code>
That'
s
it
!
Now
there
should
be
a
file
called
File
.
php
in
your
myrecords
directory
.
The
file
should
look
like
:
<
code
type
=
'php'
>
/**
* This class has been auto-generated by the Doctrine ORM Framework
* Created: Saturday 10th of February 2007 01:03:15 PM
*/
class
File
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'id'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'primary'
=>
true
,
'autoincrement'
=>
true
));
$this
->
hasColumn
(
'name'
,
'string'
,
150
);
$this
->
hasColumn
(
'size'
,
'integer'
,
8
);
$this
->
hasColumn
(
'modified'
,
'integer'
,
8
);
$this
->
hasColumn
(
'type'
,
'string'
,
10
);
$this
->
hasColumn
(
'content'
,
'string'
,
null
);
$this
->
hasColumn
(
'path'
,
'string'
,
null
);
}
public
function
setUp
()
{
}
}
</
code
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment