I'm getting the following error:
Array (
[0] => Missing table 'TEST_USERS'. If running from a test you may need to add 'app.TEST_USER' to the fixtures array. See output
below for more details.
[1] => Array
(
[className] => TESTUSER
[table] => TEST_USERS
[code] => 500
)
)
The table does not exist.
The table should not exist.
I grepped my code and found no reference to TEST_USERS, TESTUSERS or TEST.USERS.
I do have a table called USERS_TEST.
Can I get some trouble shooting hints?
Thanks!
Solution:
I changed:
var $useTable = 'TEST';
to:
var $useTable = 'test';
and it worked.
Related
I've tried this code:
//controller
$model = new Mymodel;
$table = $model->getTable();
$columns = Schema::getColumnListing($table);
//view.blade.php
{{print_r($columns)}}
but the result only give this output: Array ( [0] => * ) 1
More Information:
I need to connect to SQL Server database with Forticlient VPN. I think it shouldn't be the problem. But, tell if there's something I've missed.
After struggling looking for any answer, and looking for answer generally about how to get the column name straight from SSMS, I've made my temporary own solution. Here's the code:
$model = new Mymodel;
$table = $model->getTable();
$schema = DB::table('INFORMATION_SCHEMA.COLUMNS')
->select('COLUMN_NAME')
->where("TABLE_NAME", $table)
->get();
My own answer is only improvement from the base query to get column name straight from the SSMS, here the query:
select COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = 'mytable_name'
I'm trying to reverse generate a schema from a MSSQL database using Propel 2. I've set up my YAML configuration file as usual:
dbname:
adapter: mssql
classname: Propel\Runtime\Connection\ConnectionWrapper
dsn: "dblib:host=123.456.789.012;dbname=dbname"
user: username
password: password
attributes:
When I run the command propel reverse 'dbname' I receive the error:
[Propel\Generator\Exception\EngineException]
Column "" declared twice in table "Status"
Which is obviously thrown here:
https://github.com/propelorm/Propel2/blob/master/src/Propel/Generator/Model/Table.php#L499
#r499
Why does Propel attempt to add 'empty' columns? My SQL server management studio does not display empty columns at all when I look at the design of the DB table Status, it only displays the two columns it contains (uid and name).
Edit:
So I went digging into the code of Propel, and it seems to go wrong here:
https://github.com/propelorm/Propel2/blob/62859fd0ed3520b7d7afbbdeac113edaf160982b/src/Propel/Generator/Reverse/MssqlSchemaParser.php#L124
protected function addColumns(Table $table)
{
$dataFetcher = $this->dbh->query("sp_columns '" . $table->getName() . "'");
foreach ($dataFetcher as $row) {
$name = $this->cleanDelimitedIdentifiers($row['COLUMN_NAME']);
$table->getName() correctly returns the right table name. When I print dataFetcher it's a PDO object. However:
$row gives the following array:
Array(
[0] => My DBname
[1] => My DBprefix
[2] => Status
[3] => uid
[4] => 4
[5] => int identity
etc. no string indices hence COLUMN_NAME is empty.
(Posted on behalf of the OP):
This is a bug in the Propel MSSQL schema parser: https://github.com/propelorm/Propel2/issues/863.
I am new to ACLs in CakePHP. I believe my Administrator group is set up correctly with full access to the 'controllers' ACO. However I get an error when I try to go to any controller or action that is not explicitly made public.
Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Array
(
[User] => Array
(
[id] => 9
[email] => Admin
[group_id] => 3
[is_active] => 1
[created] => 2013-04-08 07:59:52
[modified] => 2013-04-08 07:59:52
[Group] => Array
(
[id] => 3
[name] => Administrators
[user_count] => 2
[created] => 2013-04-08 06:34:58
[modified] => 2013-04-08 06:34:58
)
)
)
Aco: controllers/Users/index [CORE/Cake/Model/Permission.php, line 94]
In my acos table there is an entry for 'controllers/Users/index' as the alias. This entry has a parent_id that references 'controllers/Users', which in turn has a parent_id which references 'controllers'.
There is only one entry in my 'aros_acos' table that is granting full permission to the Administrators group.
Based on the error above I did a little digging and found that if I directly try to call $this->Acl->Aco->node('controllers/Users/index'); the returned value is false. But if I do the same query on $this->Acl->Aco->node('controllers'); the returned value is the correct array.
Something is clearly not functioning properly but I can't figure out where I am going wrong. I have been digging in the Documentation Book and API all day and have not found any reason why 'controllers/Users/index' isn't found but 'controllers' is. At this point it seems like it has something to do with the / character but I don't know why. I used the same string when adding the Aco and it saved correctly.
Thanks!
I found the problem by installing the ACL Plugin at:
http://www.alaxos.net/blaxos/pages/view/plugin_acl_2.0
After running this great utility I found that I was incorrectly adding my ACOs with the fill path in the alias. It turns out the alias is just the action or controller name and based on the parent_id's it finds the correct path.
This is not very well documented in the CakePHP Documentation, but what else is new.
Example:
I was adding 'controllers/Users/index' instead of 'index'.
Hope this can help someone else solve this problem! I wasted an entire day on it.
I try to use alaxos acl plugin for study of Acl code
and I got error
Warning (512): AclNode::node() - Couldn't find Aro node identified by "Array
(
[Aro0.model] => Group
[Aro0.foreign_key] => admin
)
" [CORE\cake\libs\model\db_acl.php, line 191]
Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Array
(
[User] => Array
(
[id] => 76
[username] => tttttt
[group_id] => admin
[active] => 1
[activation_code] =>
[widget_count] =>
[lastvisit] =>
)
)
Aco: Users/add [CORE\cake\libs\controller\components\acl.php, line 273]
Warning (2): Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\cakephp\cake\libs\debugger.php:673) [CORE\cake\libs\
My Db picture here
User and Group Model
thank for answer
You should to set basic require data in database
it important for acl component to work right
I am following the blog tutorial and modifying it to fit my site's needs. I am having a little trouble with my view function.
function view($id = null)
{
$this->Article->articleid = $id;
$this->set('article', $this->Article->read());
}
This line does not work, I get this error: Warning (512): SQL Error: 1054: Unknown column 'Article.id' in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 681]
However, I got it to work with $this->set('article', $this->Article->find('first' , array('conditions' => array('Article.articleid' => $id))));
My schema for articles is
articleid
userid
title
text
The query has WHERE Article.id = '1'
however, thats wrong. It should be articleid instead of id
Anyway I can change this so I could use read()?
Have you specified inside the Article model that var $primaryKey = 'articleid'; ?
From the documentation:
Each table normally has a primary key, id. You may change which field name the model uses as its primary key. This is common when setting CakePHP to use an existing database table.