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
  • 52 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
  • 17608 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 | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10670 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.


 
  • pradeesh_72
  • Member
  • Trial users
  • Join Date: 15-Nov 17
  • 42 posts

Posted 13 December 2017 - 10:12 AM #6

Is there any way to find out the last inserted id in cs cart? It should have been a basic functionality.



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

Posted 13 December 2017 - 01:29 PM #7

Is there any way to find out the last inserted id in cs cart? It should have been a basic functionality.

 

This value is returned by the db_query function. E.g.

$product_id = db_query("INSERT INTO ?:products ?e", $_data);

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • pradeesh_72
  • Member
  • Trial users
  • Join Date: 15-Nov 17
  • 42 posts

Posted 14 December 2017 - 04:33 AM #8

Am using REPLACE Query. Will it work?? :confused: :confused: :confused:



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

Posted 14 December 2017 - 05:59 AM #9

Am using REPLACE Query. Will it work?? :confused: :confused: :confused:

 

Please try and inform us here :)


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10670 posts

Posted 14 December 2017 - 09:04 PM #10

Replace should also retrun the current primary key value.  Note that if this is a multiple field value that you might have to do additional parsing of the result to get to the value you want.  But 'products' uses an integer(8) unsigned key so that would be what you would get from a REPLACE INTO ?:products.....


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.


 
  • pradeesh_72
  • Member
  • Trial users
  • Join Date: 15-Nov 17
  • 42 posts

Posted 15 December 2017 - 04:40 AM #11

Am trying to install a new cs cart multivendor on a server with PHP version 7.0 and MySQL 5.7. Installation is stuck at Setup languages design/themes/responsive/styles/data. Have anyone else faced the same issue?