Replies: 3 comments
-
I figured it out. Can I place my SQL file in the plugin? or do I need to place it with the other SQL files? |
Beta Was this translation helpful? Give feedback.
-
You can run the plugin setup code like create tables on For testing you can delete This event is used by the The plugin uses the same Vvveb\System\Import\Sql class as the main install to create tables and insert initial data https://github.com/Vvveb/contact-form/blob/main/install.php You can just copy the code from the plugin and then place the sql files in the same directory structure install/sql/mysqli/schema/message.sql To write the sql queries to access data from the plugin tables you can use the same pattern Then you can use $model = model('Plugins\ContactForm\Message');
$messages = $model->getAll(['start' => 0, 'limit' => 5]);
$message = $model->get(['mesage_id' => 1]); |
Beta Was this translation helpful? Give feedback.
-
Thank You
From: Givan ***@***.***>
Date: Wednesday, November 6, 2024 at 3:06 AM
To: givanz/Vvveb ***@***.***>
Cc: ferdware ***@***.***>, Author ***@***.***>
Subject: Re: [givanz/Vvveb] I want to create some custom tables in the database to store specific data (Discussion #212)
You can run the plugin setup code like create tables on Vvveb\System\Extensions\Plugins::setup event that is triggered only once when the plugin is first activated.
For testing you can delete config/plugins.php to reset plugins state.
This event is used by the contact form plugin to create it's own tables https://github.com/Vvveb/contact-form/blob/main/plugin.php#L96-L103
The plugin uses the same Vvveb\System\Import\Sql<https://github.com/givanz/Vvveb/blob/master/system/import/sql.php#L159> class as the main install to create tables and insert initial data https://github.com/Vvveb/contact-form/blob/main/install.php
You can just copy the code from the plugin and then place the sql files in the same directory structure install/sql/mysqli/schema/message.sql<https://github.com/Vvveb/contact-form/blob/main/install/sql/mysqli/schema/message.sql>
…________________________________
To write the sql queries to access data from the plugin tables you can use the same pattern
sql/mysqli/message.sql<https://github.com/Vvveb/contact-form/blob/main/sql/mysqli/message.sql> and create your sql files in the format sql/engine/yourtable.sql
Then you can use
$model = model('Plugins\ContactForm\Message');
$messages = $model->getAll(['start' => 0, 'limit' => 5]);
$message = $model->get(['mesage_id' => 1]);
—
Reply to this email directly, view it on GitHub<#212 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABILS2UJN7NHKYHEZ5NYZNTZ7HZ3PAVCNFSM6AAAAABRIAOAEWVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCMJWGU2DGMY>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
What's the best way to query/insert/update my custom data using the current framework to access the MySQL db without using my own code to do it?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions