Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

db_query INSERT issues... Rate Topic   - - - - -

 
  • jagorny
  • Senior Member
  • Members
  • Join Date: 29-Nov 08
  • 226 posts

Posted 03 April 2013 - 06:28 PM #1

So I'm trying to do a simple insert but for some reason I keep getting an error and all the fields in my array check out. Do I need to provide value pairs for every field?

When I try to run this simple code:

$shipment_load = array(
  "shipping_id" => $record_unser[6]["shipping"],
  "carrier" => $record_unser[6]["carrier"],
  "tracking_number" => $record_unser[6]["tracking_number"],
  "timestamp" => $srkey["timestamp"]+(60*60*24),
  "comment" => ""
);
$shipment_load_id = db_query("INSERT into ?:shipments ?e", $shipment_load);

I get the following error:

Database error: Table 'cscart.cscart_' doesn't exist (1146)
Invalid query: SHOW COLUMNS FROM cscart_

I don't understand why the table to insert is disappearing during the course of the query. I can insert non-variable values that are appropriately typed and nothing seems to work. Is the format for this different in 2.2.5?
Jacob Gorny

www.orthodoxmarketplace.com - CS-Cart 2.2.4 Pro (Dedicated)

 
  • jagorny
  • Senior Member
  • Members
  • Join Date: 29-Nov 08
  • 226 posts

Posted 03 April 2013 - 08:39 PM #2

Never mind. The replacement regex that detect database operations is case sensitive - changing 'INSERT into' to 'INSERT INTO' resolved the problem.
Jacob Gorny

www.orthodoxmarketplace.com - CS-Cart 2.2.4 Pro (Dedicated)

 
  • abcd
  • Advanced Member
  • Trial users
  • Join Date: 10-Sep 16
  • 50 posts

Posted 17 April 2017 - 05:19 AM #3

How to insert date in date format instead of timestamp in database??

Can anyone tell me the insert query for that???

Thanks in adv!



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 14,992 posts

Posted 17 April 2017 - 08:28 AM #4

How to insert date in date format instead of timestamp in database??

Can anyone tell me the insert query for that???

Thanks in adv!

 

Please provide us with more details about this request. What input data do you have? What table do you use?


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration

Certified CS-Cart RU Developer | Сертифицированный разработчик на CS-Cart Русская Версия

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 9,895 posts

Posted 17 April 2017 - 07:35 PM #5

MySQLnative date/time format is YYYY-MM-DD HH-MM-SS so you simply enter the data as a string or use any of the internal functions like NOW(). assuming the field is datetime.

 

I.e. 

db_query("INSERT INTO ?:foo SET my_date=NOW(), id=123");
or
$now=date("Y-M-D H:i:s", TIME);
INSERT INTO ?:foo SET my_date=?s id=123", $now);

 

But note that much of cs-cart expects a UNIX timestamp for date/time operations versus a datetime type or a date string.

 

Suggest you look at the mySQL manual for Datetime.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.