I have an extension, that works fine on TYPO3 6.2 and 7.4. I try to run ist on TYPO3 8.7.
The problem is, that the values of my database result object are null except uid and pid.
I use $this->subjectRepository->findAll(); and I tried to use individual queries. The result is the same.
$query = $this->createQuery();
$query->statement('SELECT * FROM tx_libconnect_domain_model_subject WHERE deleted = 0 AND hidden = 0');
$query->execute();
This is the dump of the query:
TYPO3\CMS\Extbase\Persistence\Generic\Queryprototypeobject
type => protected'Sub\Libconnect\Domain\Model\Subject' (35 chars)
objectManager => protectedTYPO3\CMS\Extbase\Object\ObjectManagersingletonobjectfiltered
dataMapper => protectedTYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMappersingletonobjectfiltered
persistenceManager => protectedTYPO3\CMS\Extbase\Persistence\Generic\PersistenceManagersingletonobjectfiltered
qomFactory => protectedTYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactorysingletonobjectfiltered
source => protectedTYPO3\CMS\Extbase\Persistence\Generic\Qom\Selectorprototypeobject
nodeTypeName => protected'Sub\Libconnect\Domain\Model\Subject' (35 chars)
selectorName => protected'tx_libconnect_domain_model_subject' (34 chars)
constraint => protectedNULL
statement => protectedTYPO3\CMS\Extbase\Persistence\Generic\Qom\Statementprototypeobject
statement => protected'SELECT * FROM tx_libconnect_domain_model_subject WHERE deleted = 0 AND hidde
n = 0' (81 chars)
boundVariables => protectedarray(empty)
orderings => protectedarray(empty)
limit => protectedNULL
offset => protectedNULL
querySettings => protectedTYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettingsprototypeobject
respectStoragePage => protectedTRUE
storagePageIds => protectedarray(1 item)
ignoreEnableFields => protectedFALSE
enableFieldsToBeIgnored => protectedarray(empty)
includeDeleted => protectedFALSE
respectSysLanguage => protectedFALSE
languageOverlayMode => protected'1' (1 chars)
languageMode => protected'content_fallback' (16 chars)
languageUid => protected0 (integer)
usePreparedStatement => protectedFALSE
useQueryCache => protectedTRUE
The dump of the result object on TYPO3 8.7:
object(Sub\Libconnect\Domain\Model\Subject)#886 (10) { ["title":protected]=> NULL ["dbisid":protected]=> NULL ["ezbnotation":protected]=> NULL ["uid":protected]=> int(2) ["_localizedUid":protected]=> int(2) ["_languageUid":protected]=> NULL ["_versionedUid":protected]=> int(2) ["pid":protected]=> int(1) ["_isClone":"TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject":private]=> bool(false) ["_cleanProperties":"TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject":private]=> array(5) { ["title"]=> NULL ["dbisid"]=> NULL ["ezbnotation"]=> NULL ["uid"]=> int(2) ["pid"]=> int(1) } }
On TYPO3 6.2:
object(Sub\Libconnect\Domain\Model\Subject)#1078 (10) { ["title":protected]=> string(29) "Allgemein / Fachübergreifend" ["dbisid":protected]=> string(2) "28" ["ezbnotation":protected]=> string(2) "AZ" ["uid":protected]=> int(2) ["_localizedUid":protected]=> int(2) ["_languageUid":protected]=> NULL ["_versionedUid":protected]=> int(2) ["pid":protected]=> int(1) ["_isClone":"TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject":private]=> bool(false) ["_cleanProperties":"TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject":private]=> array(5) { ["title"]=> string(29) "Allgemein / Fachübergreifend" ["dbisid"]=> string(2) "28" ["ezbnotation"]=> string(2) "AZ" ["uid"]=> int(2) ["pid"]=> int(1) } }
Do you have any idea? Thanks a lot.
Sounds like the TCA is not valid.
There were some changes in TCA in the last major updates, e.g.:
The required field "renderType" when using a select
You have to use the tablename as filename for the TCA definitions
You need to move the TCA file for each table into the folder Configuration/TCA
You can see the TCA reference here: https://docs.typo3.org/typo3cms/TCAReference/
Related
I'm trying to create a form to publish expense reports in my project.
In the form I set the totalPrice field as a NumberType with scale 2:
$builder
->add('totalPrice', MoneyType::class, array(
'currency' => '',
'scale' => 2,
'label' => false,
'attr' => array(
'placeholder' => 'Prix'
)))
In my ExpenseReport entity, my totalPrice column is like this:
/**
* #ORM\Column(type="float", nullable=false, name="totalPrice")
*/
private $totalPrice;
I tried with type="decimal", precision=6, precision=2 but it's not working too.
THE ERROR
If I dump my $report viariable in the Controller, I get this from the form (totalPrice is supposed to be 19.99 but now the price is a field of the $report array):
ExpenseReport {#572 ▼
-id: null
-owner: null
-date: DateTime #1527531970 {#573 ▶}
-totalPrice: null // WTF ???
-attachement: UploadedFile {#32 ▶}
-statut: null
-refundedPortion: null
-lastStatutUpdate: null
-statutUpdateBy: null
+"19.99": 19.99 // my price is now a field of the array ??
}
I have TYPO3 7.6.18 and I am making ajaxDispatcher. I stay on final study. I trying to call $this->bootstrap->run( '', $this->configuration ); but it get an error. I can't know what this error is exactly. But I'm sure problem in this line.
My $this->configuration is:
array(8) {
["pluginName"] => string(7) "Piphoto"
["vendorName"] => string(5) "Istar"
["extensionName"] => string(7) "feFiles"
["controller"] => string(5) "Photo"
["action"] => string(4) "test"
["mvc"] => array(1) {
["requestHandlers"] => array(1) {
["TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler"] =>
string(48) "TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler"
}
}
["settings"] => array(2) {
["adminemail"] => string(15) "mvnaz#yandex.ru"
["pageShowPhotoId"] => string(2) "32"
}
["persistence"] => array(1) {
["storagePid"] => string(2) "31"
}
}
Action test is allowed in local_conf. The Vendor is set right, extension name, plugin and controller too.
Sorry)
["extensionName"]=>
string(7) "fefiles"
fefiles need Fefiles - uppercase!
Thank you all for help! )
I write a fileds like this
$fileds = array(
'id' => array('type' => 'integer','AUTO_INCREMENT'=>true),
'user' => array('type' => 'text'),
'time' => array('type' => 'integer')
);
When I run thisDBUtil::create_table($table, $fileds);
it turn wrong,
exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 near "AUTO_INCREMENT": syntax error' in /home/yangjun/phpenv/public_html/cmanage/fuel/core/classes/database/pdo/connection.php:239
What is wrong ?
ihave rewrite a new test,and add primary key,but doesn't work,i read the document in fuelphp,no idea~
<?php
/**
* #group test
*/
class Test extends TestCase
{
public static function setUPBeforeClass()
{
DBUtil::set_connection('request');
$table = 'test';
$fileds = array(
'_id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true),
'_name' => array('type' => 'test'),
'_data' => array('type' => 'test')
);
$primary_keys = array('_id');
DBUtil::create_table($table, $fileds, $primary_keys);
}
public function test_add_keycode_request()
{
$RequestData = array(
'_id' => '',
'_name' => 'hhh',
'_data' => 'ggg');
$RequestData1 = array(
'_id' => '',
'_name' => 'hhhh',
'_data' => 'gggg');
self::add_request($RequestData);
self::add_request($RequestData1);
Cli::write(__METHOD__ . " √ \n", 'green');
}
public static function add_request($RequestData)
{
try {
$result = \DB::insert('test')
->set($RequestData)
->execute('request');
} catch (\Database_Exception $e) {
\Log::error('DB access Error' . $e);
throw $e;
}
return $result;
}
}
error log,this is whole error log,synatax error?
Test
1.exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 near "AUTO_INCREMENT": syntax error' in /home//phpenv/public_html/fuel/core/classes/database/pdo/connection.php:239
2.Next exception 'Fuel\Core\Database_Exception' with message 'SQLSTATE[HY000]: General error: 1 near "AUTO_INCREMENT": syntax error with query: "CREATE TABLE IF NOT EXISTS "test" (
"_id" int(11) NOT NULL AUTO_INCREMENT,
"_name" test NOT NULL,
"_data" test NOT NULL,
PRIMARY KEY "_id" ("_id"));"' in /home/yangjun/phpenv/public_html/fuel/core/classes/database/pdo/connection.php:272
Seems is missing the constraint param on columns field (i don't know also if int or integer type field).
Try this:
$fileds = array(
'id' => array('constraint' => 11,'type' => 'integer','AUTO_INCREMENT'=>true),
'user' => array('type' => 'text'),
'time' => array('constraint' => 11, 'type' => 'integer'))
}
UPDATE
Need to specify the primary key also:
DBUtil::create_table($table, $fileds, array('id'));
More info in the doc here
Hope this help
I have MySQL database for store data. Some field is type decimal. I don't know why zend_db always fill zero pad for decimal type field.
public function getListings() {
$select = $this->getDb()->select()
->from($this->_tableName, array('listing_sell_price', 'listing_sell_total_price'));
return $select->query()->fetchAll();
}
When I try to var_dump all data from model
$listings = RW_Model_Listing::getInstance()->getListings();
var_dump($listings);
There is zero padding
array(2) {
[0]=> array(2) { ["listing_sell_price"] => string(10) "0004750000", ["listing_sell_total_price"] => string(10) "0004750000"}
[1]=> array(2) { ["listing_sell_price"] => string(10) "0000008000", ["listing_sell_total_price"] => string(10) "0000008000"}
}
Any solution for removing zero pad ?
Best regard,
Brian
Okay it's my stupidity.
I forgot to uncheck ZeroFill in my Table Configuration LoL
If you have a complex SQL query involving many joins (for example returning Articles with their associated many to many Tags) is there anything in Zend Framework that will produce the lovely CakePHP style database results:
Array
(
[0] => Array
(
[ModelName] => Array
(
[id] => 83
[field1] => value1
[field2] => value2
[field3] => value3
)
[AssociatedModelName] => Array
(
[id] => 1
[field1] => value1
[field2] => value2
[field3] => value3
)
)
)
I don't mind if it's an object rather than an array, I just wondered if by using Zend_Db_Table to build a SELECT JOIN query I could save some leg work and get some nicely formatted results.
Here is the kind of code I'm using to build the query:
$select = $db->select(Zend_Db_Table::SELECT_WITH_FROM_PART);
$select->from('tableName','fieldName')
->join('joinTable', 'joinTable.keyId = tableName.keyId',array())
->where('tableName.userId = ?', $userId);
$resultSet = $db->fetchAll($select);
Nothing as pretty as what you're used to just the data I asked for.
The normal Result would be a rowset object, however the ->toArray() is available for most *Zend_DbTable_Abstract* methods.
The $result->toArray() truncated and dumped using Zend_debug::dump():
Lead Tracks array(7) {
[0] => array(9) {
["trackid"] => string(2) "24"
["weekendid"] => string(1) "8"
["shiftid"] => string(1) "1"
["bidlocationid"] => string(1) "1"
["qty"] => string(1) "2"
["lead"] => string(1) "1"
["bidloc"] => string(14) "out of service"
["deptcode"] => string(3) "491"
["stationid"] => string(1) "1"
}
The query:
where = $this->select(Zend_Db_Table::SELECT_WITH_FROM_PART)
->setIntegrityCheck(FALSE);
$where->where('track.bidlocationid = ?', $bidlocationId)
->where('lead = ?', $lead)
->join('bidlocation', 'bidlocation.bidlocationid = track.bidlocationid')
->where('bidlocation.stationid = ?', $stationId)
->order('shiftid ASC')
->order('weekendid ASC');
$result = $this->fetchAll($where);
sorry, just utility :)