Welcome Guest, Not a member yet? Register   Sign In
CI generator for crud (bash and php) 0.1
#21

[eluser]MikeHibbert[/eluser]
Great! glad it works on some else system Big Grin

If anyone else has test this and has feedback please post

Mike
#22

[eluser]Dreammaker[/eluser]
Ooops.

Mike, I hurried. I tested the generator, but not generated classes Sad They didn't want to work.

Example for MVCs based on default yaml (poo.yml)

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: rules

Filename: controllers/poo.php

Line Number: 25

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: fields

Filename: controllers/poo.php

Line Number: 27

And another same warnings in view:
Code:
Message: Undefined property: CI_Validation::$name

Filename: poo/add_view.php


Line Number: 13
Code:
Message: Undefined property: CI_Validation::$cheese

Filename: poo/add_view.php

Line Number: 15
Code:
Message: Undefined property: CI_Validation::$cheese2

Filename: poo/add_view.php

Line Number: 16
#23

[eluser]Dreammaker[/eluser]
Hm, this errors occured cause generator takes fieldnames from command line arguments. But if we have a yaml-file we should base the work on it (or not?).

Also if

roman@sunion:~/public_html/test$ php crud/create a poo name address cheese cheese2

We have in view:

Code:
<textarea name="address" id="address"><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined variable: address</p>
<p>Filename: poo/add_view.php</p>
<p>Line Number: 14</p>

</div>&lt;/textarea&gt;

'cause :
Code:
<label for="address">address</label>&lt;textarea name="address" id="address"&gt;&lt;?=$address?&gt;&lt;/textarea&gt;&lt;br/>

&lt;?=$address?&gt;
#24

[eluser]MikeHibbert[/eluser]
Hey Dreammaker

Ok so you have create the table for yourself in phpmyadmin or whatever mysql admin you use, and it has the feilds in there first?

The generator doesn't as yet create tables or fields in mysql, although I think it should myself.

So, as a result CI is looking for variables that arent being created from database.

That's my first reaction of course, other things to check for is that you run the command with the 'a' option first, which you appear to have done.

Let me know if you've already done that and I will try and recreate the errors myself.

Mike
#25

[eluser]MikeHibbert[/eluser]
Also, The yaml is only used at the moment to create the actual forms in the views.

So currently, when you run the generator you will need to have the table and fields on the command too.

Mike
#26

[eluser]Dreammaker[/eluser]
Code:
CREATE TABLE IF NOT EXISTS `poo` (
  `name` char(255) COLLATE utf8_unicode_ci NOT NULL,
  `address` char(255) COLLATE utf8_unicode_ci NOT NULL,
  `cheese` char(255) COLLATE utf8_unicode_ci NOT NULL,
  `cheese2` char(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Code:
roman@sunion:~$ cd ~/public_html/test
roman@sunion:~/public_html/test$ php crud/create a poo name address cheese cheese2
Array
(
    [tablename] => poo
    [name] => text
    [address] => textarea
    [cheese] => checkbox
    [cheese2] => file
)

Generating model...
Generating controller...
Generating Views...
texttextareacheckboxfiletexttextareacheckboxfile
roman@sunion:~/public_html/test$

Code:
&lt;form action="/poo/add" method="post"&gt;
    <fieldset><label for="name">name</label>        &lt;input type="text" name="name" id="name" value=""&gt;&lt;br/>
<label for="address">address</label>&lt;textarea name="address" id="address"&gt;&lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined variable: address</p>
<p>Filename: poo/add_view.php</p>
<p>Line Number: 14</p>

</div>&lt;/textarea&gt;&lt;br/>
    <label for="cheese">cheese</label>    &lt;input type="checkbox" name="cheese" id="cheese" value="1"&gt;&lt;br/>
<label for="cheese2">cheese2</label>        &lt;input type="file" name="cheese2" id="cheese2" value=""&gt;&lt;br/>
&lt;input type="submit" name="submit" value="Add"&gt;
    </fieldset>

&lt;/form&gt;
#27

[eluser]MikeHibbert[/eluser]
Ok its seems its all my fault Big Grin

I fixed this error and it seemd to be fine now.

I've attached the new version so you can give that a whirl Big Grin

Mike
#28

[eluser]Dreammaker[/eluser]
After redirect
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$id

Filename: poo/list_view.php

Line Number: 16
A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$id

Filename: poo/list_view.php

Line Number: 17

Smile
#29

[eluser]MikeHibbert[/eluser]
you need to add a unique key to your table called 'id' for every table you want to use with the system too:

Code:
CREATE TABLE IF NOT EXISTS `poo` (
  `id`  INT( 11 ) NOT NULL AUTO_INCREMENT,
  `name` char(255) COLLATE utf8_unicode_ci NOT NULL,
  `address` char(255) COLLATE utf8_unicode_ci NOT NULL,
  `cheese` char(255) COLLATE utf8_unicode_ci NOT NULL,
  `cheese2` char(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Then you wont be making duplicate entries in the DB

Mike
#30

[eluser]Dreammaker[/eluser]
Ok. It works. Smile

Next bugs:

1. In "Edit" mode Textarea is not filled.
2. Also in "Edit" mode a file field works as new field and it generates error when form is submitted.




Theme © iAndrew 2016 - Forum software by © MyBB