I found your doc about jobeet project.
I'm testing (last 4.1b1 version) it step by step, but in day 3 I've error, I think:
model Category it'd be
class Model_Category extends Model_Table {
public $entity_code='category';
public $table_alias='c';
//...........
model Job it'd be
class Model_Job extends Model_Table {
public $entity_code='job';
public $table_alias='j';
//.......
Right?
And now, from here I've error after call generate.html
PathFinder_Exception
Unable to include Model\.php
Additional information:
type: php
attempted_locations: Array ( [0] => D:/xampp/htdocs/atk4jobeet/lib/Model\.php [1] => D:\xampp\htdocs\atk4jobeet\atk4/lib/Model\.php [2] => D:/xampp/htdocs/atk4jobeet/atk4-addons/mvc/Model\.php [3] => D:/xampp/htdocs/atk4jobeet/atk4-addons/misc/lib/Model\.php )
Is it problem in class page_generate extends Page_SchemaGenerator?
It waiting for GET[model] param, but day3 write:
If you are willing for Agile Toolkit to generate SQL CREATE code for you, you can set up a page for that. Code generator exists as a class, but you need to enable it in order to use it. Add file page/generate.php with the following content:
class page_generate extends Page_SchemaGenerator {}
Next navigate to http://localhost/jobeet/generate.html in your browser, pick Category model and click Generate button. The schema code will be shown on the right. You can also click "Generate" checkbox and "create" statement will be evaluated by sql automatically. Once you create 'Category' proceed to create 'Job'.
Where problem is?
Yes, actually i have done changes for the generator while writing jobeet doc. In your case you can add ?model=Job to the URL. Otherwise you can use git version.
BTW - there is a branch for day3 in the jobeet repository:
https://github.com/romaninsh/jobeet/tree/day3
Related
I wasnt getting any errors before. But today, i entered my project to edit and saw these errors.
First one is on this line;
public final class NoteDao_Impl implements NoteDao {
// The error code is : Class 'NoteDao_Impl' must either be declared abstract or implement abstract method 'getAllNotes(Continuation<? super List<? extends Notes>>)' in 'NoteDao'
I can fix it with Alt + Enter and then clicking 'implement methods' but just in case i want to write it.
The second one and third one is on these lines;
#Override
// Error : Method does not override method from its superclass
public Object getAllNotes(final Continuation<? super List<Notes>> continuation) {
// Error : 'getAllNotes(Continuation<? super List<Notes>>)' in 'com.ahmetkaan.kediy.data.NoteDao_Impl' clashes with 'getAllNotes(Continuation<? super List<? extends Notes>>)' in 'com.ahmetkaan.kediy.data.NoteDao'; both methods have same erasure, yet neither overrides the other
The NoteDao;
package com.ahmetkaan.kediy.data
import androidx.room.*
#Dao
interface NoteDao {
#Query("SELECT * FROM notes ORDER BY id DESC")
suspend fun getAllNotes() : List<Notes>
#Query("SELECT * FROM notes WHERE id =:id")
suspend fun getSpecificNote(id:Int) : Notes
#Query("SELECT * FROM notes WHERE category = :id")
suspend fun getCategoryNote(id:Int) : Notes
#Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertNotes(note:Notes)
#Delete
suspend fun deleteNote(note:Notes)
#Query("DELETE FROM notes WHERE id =:id")
suspend fun deleteSpecificNote(id:Int)
#Update
suspend fun updateNote(note:Notes)
}
The problem appears when i set getAllNotes() method as "getAllNotes() : List " So i guess thats why. But i dont understand why i get this error now. I do some research and i encounter some solutions like;
public class a<T extends Comparable> implements A<T>
but probably i cant make it compatible with my project :,) Thanks in advance.
I met the same problem. I try this link to fix the problem.
You can try changing List<Notes> to Array<Notes>.
Hope it will help.
Also, if this error causes your app to crash at runtime, and you don't want to change the List to Array, maybe there is another approach. If you are using manual migration of the room database, try to change it to auto migration(Doc). Although there still has this error in the build package, it won't affect your app performance. Your app can run without crashing.
I have some custom content types that I need to be able to import and export. All these types are created from modules.
Most of them didn't have a problem at all because I used custom database columns. I found a solution for exporting them here, and it works perfectly.
I have one that I created from the migration, and added a text field and a boolean field using WithField().
My problem is that when I export, only the metadata gets exported, not the data.
My migration looks like this:
public int Create()
{
SchemaBuilder.CreateTable("TopDealBundleRecord", table => table
.ContentPartRecord()
);
ContentDefinitionManager.AlterPartDefinition(
"TopDealBundle", builder => builder
.Attachable()
.WithField("BundleID", f => f.OfType(typeof(TextField).Name)
.WithDisplayName("Bundle ID"))
.WithField("MobileOnly", f => f.OfType(typeof(BooleanField).Name)
.WithDisplayName("Mobile only?"))
);
ContentDefinitionManager.AlterTypeDefinition("TopDealBundle", cfg => cfg
.Creatable()
.Draftable()
.WithPart("TitlePart")
.WithPart("IdentityPart")
.WithPart("PublishLaterPart")
.WithPart("TopDealBundle")
.WithPart("CommonPart"));
return 1;
}
And my Model is basically empty (I'm sure I'm missing something here, but I don't know how to declare the TextField, and how to get and set it):
public class TopDealBundleRecord : ContentPartRecord
{
}
public class TopDealBundle : ContentPart<TopDealBundle>
{
}
My driver doesn't have the Importing/Exporting methods yet, those are the ones I want to add somehow.
Thank you for the help in advance!
I have the following test case in my CakePHP (2.0.1) app:
<?php
public function testGetTenUsers() {
$users = $this->User->find('all' , array('limit' => 10));
// .... assert some things
}
?>
This works fine, and returns 10 records from my fixture.
When I add the Translate behaviour to my User model, this test no longer works (returns empty array).
Not sure how to approach this. Do I create an I18n fixture, or unbind the behaviour?
Any help appreciated.
Like you just stated, the best solution is to create a fixture.
Unbinding this behavior will make your tests less likely to catch errors. My point is: The further you are from your production configuration, the more complex it becomes to find bugs and quirks.
Here is my default fixture for i18n:
<?php
// I'm working in CakePHP 1.3 at the moment
class I18nFixture extends CakeTestFixture {
public $name = 'I18n';
public $table = 'i18n';
public $import = array(
'table'=>'i18n',
'records'=>true
);
}
I imported the rows in my i18n table from the default configuration, because I only have static content in it (i.e. translation for types, roles). I wouldn't recommend doing this if you have many user input stored in it.
Please also note that you have to specify the table name in the fixture if you want to avoid the inflector to kick in. (so your table name stays "i18n" and not "i18ns")
I am writing a personal bookmarks application and am looking for a way to have totally different content between subdomains.
I have written the application and it works fine, but have yet to implement multiple collections. I have the following models:
Tag (unused so far)
Bookmark
Subject
Bookmarks are categorized in subjects and I'm planning to allow tagging in the future and see if that helps me manage my bookmarks more easily.
The current problem I have is that I'd like to separate bookmarks as a whole. I want to use subdomains like webdevelopment.bookmarks.local, languages.bookmarks.local, linux.bookmarks.local that work with an entire own set of domains and bookmarks.
I am considering adding a new model called Set (short for "bookmark sets") and defining sets based on the subdomain.
According to that plan I'd have to rewrite all $this->...->find-queries in the entire App to contain the condition "set_id" = $SubdomainBasedSetid".
While it wouldn't be that much work, I was wondering if it could be done smarter, maybe that Cake would only see the relevant bookmark set per subdomain.
well, your solution is right. But instead of using subdomains, you can use prefix, so you don't have check and set yourself. Since you use subdomains, I assume that these sets are fixed or rarely change. So you don't really need a sets table, just use the set name directly in your bookmark record, so you don't have to convert between name and id.
According to that plan I'd have to rewrite all $this->...->find-queries in the entire App to contain the condition "set_id" = $SubdomainBasedSetid".
As all models extend AppModel, it is possible to edit all queries there before they happen (ie. DRY). :)
// app/app_model.php
class AppModel extends Model {
public function beforeFind($queryData) { // old query
// make changes
return $queryData; // new query
}
However, if you don't want this functionality for all models (or even if you do for now), a better place might be a behavior as this allows you to pick and choose where and when it is loaded:
// app/models/behaviors/subdomain.php
class SubdomainBehavior extends ModelBehavior {
protected $_defaults = array('field' => 'Site.subdomain');
public function setup(&$model, $config = array()) {
$this->settings[$model->alias] = array_merge($this->_defaults, $config);
}
public function beforeFind(&$model, $queryData) {
$domain = $_SERVER['SERVER_NAME'];
$subdomain = substr($domain, 0, strpos($domain, "."));
$queryData['conditions'][$this->settings['field']] = $subdomain;
return $queryData;
}
}
// app/app_model.php
class AppModel extends Model {
$actsAs = array('Subdomain' => array('field' => 'Set.slug'));
}
Tag (unused so far)
To save reinventing the wheel, you may want to look at CakeDC's tags and utils plugins (the latter contains SluggableBehavior which will help with generating friendly URL parts, such as the subdomains).
I'm looking for some help understanding how to generate pages from a database to create a catalog of items, each with different URLs. All I can seem to find through google are products that will do this for me, or full e-commerce solutions. I don't want a shopping cart! Just an inventory.
Also, perhaps someone could recommend their favorite/the best simple login solution.
Thank you so much for your time and any help, suggestions, comments, solutions.
I just posted a thorough solution to another question that is very closely-related to this question. I'll re-post it here for your convenience:
I would suggest using some of the MVC (Model, View, Controller) frameworks out there like KohanaPHP. It is essentially this. You're working in a strictly Object-Oriented environment. A simple page in Kohana, build entirely from a class would look like this:
class Home_Controller extends Controller
{
public function index()
{
echo "Hello World";
}
}
You would then access that page by visiting youur url, the class name, and the method name:
http://www.mysite.com/home/ (index() can be called after home/, but it's implicit)
When you start wanting to bring in database-activity, you'll start working with another Class called a Model. This will contain methods to interact with your database, like the following:
class Users_Model extends Model
{
public function count_users()
{
return $this->db->count_records('users');
}
}
Note here that I didn't write my own query. Kohana comes with an intuitive Query Builder.
That method would be called from within your Controller, the first class that we mentioned at the beginning of this solution. That would look like this:
class Home_Controller extends Controller
{
public function index()
{
$usersModel = new Users_Model;
$userCount = $usersModel->count_users();
echo "We have " . $userCount . " users!";
}
}
Eventually, you'll want more complicated layouts, which will involve HTML/CSS/Javascript. At this point, you would introduce the "Views," which are just presentation layers. Rather than calling echo or print from within the Controller, you would load up a view (an HTML page, essentially) and pass it some variables:
class Home_Controller extends Controller
{
public function index()
{
$myView = new View("index");
$usersModel = new Users_Model;
$userCount = $usersModel->count_users();
$myView->userCount = $userCount;
$myView->render(TRUE);
}
}
Which would load the following "View"
<p>We have <?php print $userCount; ?> users!</p>
That should be enough to get you started. Using the MVC-style is really clean, and very fun to work with.
There's a lot of tools out there for generating a web interface around a data model. I find Django pretty easy to use. Based on its popularity, I'm sure that Ruby on Rails is another viable option.