I’ve tried removing an eav_entity_attribute using this code:
$entAttr = Mage::getModel('eav/entity_attribute')->getCollection()
->addFieldToFilter('attribute_set_id',$set->getId())
->addFieldToFilter('attribute_id',$attId)->getFirstItem();
$entAttr->delete();
but it doesn’t work. I receive this error: Column not found: 1054 Unknown column ‘attribute_set_id’ in ‘where clause’’
How can I delete an eav_entity_attribute this way?
Mage::getModel('catalog/resource_eav_attribute')->loadByCode('catalog_product','attribute_name')->delete();
or to delete it directly from the attribute set:
$setup = Mage::getModel('eav/entity_setup);
$setup->startSetup();
$setup->deleteTableRow('eav/entity_attribute',
'attribute_id',$setup->getAttributeId('catalog_product','attribute_code_here'),'attribute_set_id',$setup->getAttributeSetId('catalog_product', 'Default')
);
$setup->endSetup();
Related
I make this simple test:
public function test_my_awesome_test()
{
$user = User::find(1);
$response = $this->actingAs($user)->get('/awesome/test');
$response->assertStatus(200);
}
But after run test it's display me error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table
'testing.users' doesn't exist (SQL: select * from users where
users.id = 1 limit 1)
I had this same error if I needed to print some data from database. This tables exist and website works correctly. Who know where is problem?
According to the Laravel documentation, Sail overrides the DB name you defined in the .env file when you run the tests. You need to remove the following line from your phpunit.xml file:
<env name="DB_DATABASE" value="testing"/>
make .testing file in root of project and set database connection config like .env file in that . if you run a test , laravel use .testing instead of .env to read enviroment
I am using laravel 5.5 and checking event checking if slot available between 2 times using this query:
$schedules->where('id', $id)
->wherebetween($date, ['start','end'])
->orwherebetween($endTime, ['start','end'])
->orwherebetween('start', [$date,$endTime])
->orderBy('start')->get();
getting this error
"message": "SQLSTATE[42S22]: Column not found: 1054 Unknown column
'2019-03-06 13:00:00' in 'where clause'
its because the 1st parameter should be the name of the column:
you should change your code to:
->wherebetween('column name', ['1st date','2nd date'])
->orwherebetween('column name', ['1st date','2nd date'])
I have fixed that by adding DB::raw() read more
$schedules->where('id', $id)
->wherebetween(DB::raw($date), ['start','end'])
->orwherebetween(DB::raw($endTime), ['start','end'])
->orwherebetween('start', [$date,$endTime])
->orderBy('start')->get();
I am trying to add some computed columns to a SparkR data frame, as follows:
Orders <- withColumn(Orders, "Ready.minus.In.mins",
(unix_timestamp(Orders$ReadyTime) - unix_timestamp(Orders$InTime)) / 60)
Orders <- withColumn(Orders, "Out.minus.In.mins",
(unix_timestamp(Orders$OutTime) - unix_timestamp(Orders$InTime)) / 60)
The first command executes ok, and head(Orders) reveals the new column. The second command throws the error:
15/12/29 05:10:02 ERROR RBackendHandler: col on 359 failed
Error in select(x, x$"*", alias(col, colName)) :
error in evaluating the argument 'col' in selecting a method for function
'select': Error in invokeJava(isStatic = FALSE, objId$id, methodName, ...) :
org.apache.spark.sql.AnalysisException: Cannot resolve column name
"Ready.minus.In.mins" among (ASAP, AddressLine, BasketCount, CustomerEmail, CustomerID, CustomerName, CustomerPhone, DPOSCustomerID, DPOSOrderID, ImportedFromOldDb, InTime, IsOnlineOrder, LineItemTotal, NetTenderedAmount, OrderDate, OrderID, OutTime, Postcode, ReadyTime, SnapshotID, StoreID, Suburb, TakenBy, TenderType, TenderedAmount, TransactionStatus, TransactionType, hasLineItems, Ready.minus.In.mins);
at org.apache.spark.sql.DataFrame$$anonfun$resolve$1.apply(DataFrame.scala:159)
at org.apache.spark.sql.DataFrame$$anonfun$resolve$1.apply(DataFrame.scala:159)
at scala.Option.getOrElse(Option.scala:120)
at org.apache.spark.sql.DataFrame.resolve(DataFrame.scala:158)
at org.apache.spark.sql.DataFrame$$anonfun$col$1.apply(DataFrame.scala:650)
at org.apa
Do I need to do something to the data frame after adding the new column before it will accept another one?
From the link, just use backsticks, when accessing the column, e.g.:
From using
df['Fields.fields1']
or something, use:
df['`Fields.fields1`']
Found it here: spark-issues mailing list archives
SparkR isn't entirely happy with "." in a column name.
I'm writing an importer that creates new attribute (which works) and now I want to set different attribute values for different products, without using attribute sets. A method that seems to work for a lot of people seems to be the following:
Mage::getSingleton('catalog/product_action')
->updateAttributes([$id], ['color'=>'red'], self::STORE_ID);
Sadly this errors for me:
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'attribute_id' in 'where clause'' in /vagrant/htdocs/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /vagrant/htdocs/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /vagrant/htdocs/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /vagrant/htdocs/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /vagrant/htdocs/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#4 /vagrant/htdocs/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('DELETE FROM `ca...', Array)
#5 /vagrant/htdocs/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('DELETE FROM `ca...', Array)
#6 /vagrant/htdocs/lib/Zend/Db/Adapter/Abstract.php(664): Varien_Db_Adapter_Pdo_Mysql->query('DELETE FROM `ca...')
#7 /vagrant/htdocs/app/code/core/Mage/Catalog/Model/Resource/Abstract.p in /vagrant/htdocs/lib/Zend/Db/Statement/Pdo.php on line 235
Is there a better method or am I just doing something wrong?
In order to save attribute values for product, you have to load product object first then set attribute values.. See the example below:
$id = 102; // Your product id
$product = Mage::getModel("catalog/product")->load($id);
$product->setStatus(1);
$product->setColor("red");
$product->save();
As I have learned a very good and performant way is to work with the Resource model:
$product = Mage::getModel('catalog/product');
$product->setId($productId);
$product->setStoreId($storeId);
$product->setColor('red');
// or
// $product->setDataUsingMethod('color', 'red')
$resource = Mage::getResourceModel('catalog/product');
$resource->saveAttribute($product, 'color');
I have got problem with ci_session. When I am creating query with Active Record and I use session, it throws me Error Number: 1054.
It is caused by Session.php . I am using database session and when it executes sess_write(), then it throws error.
Can I create new instance of $this->db ?
Error is at line no. 289 in Session.php
$this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));
In this place is set $this->CI->db->order_by(‘something’), from my code, before I call $this->session and this is my problem.
EDIT (13:12):
Unknown column 'contract.created' in 'order clause'
UPDATE `ci_sessions` SET `last_activity` = 1393330303, `user_data` = 'some_data' WHERE `session_id` = 'ea330d7194f902b6b38b88d509766560' ORDER BY `contract`.`created` DESC LIMIT 30
Filename: C:\Apache24\htdocs\Trokadero_v5\system\database\DB_driver.php
EDIT 2:
I am sure, it is happening by Active Record , because sequence of AR tasks is:
My_controller.php
$this->db->order_by('contract.created', 'DESC');
$this->session->set_flashdata('order_by_direction', 'DESC');
And then is executing in Session.php, with my own order_by clause
$this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));
I got it.
$this->session->userdata();
$this->session->set_userdata();
etc.
MUST BE used before/after execute your own CRUD ($this->db->...).
In your controller, you have to reset the db query.
$this->db->order_by('contract.created', 'DESC');
// add line of code to get data. After getting data, reset the db object.
$this->db->_reset_write();
$this->session->set_flashdata('order_by_direction', 'DESC');